wtt-connect 0.2.18 → 0.2.20

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.
Files changed (319) hide show
  1. package/package.json +2 -5
  2. package/src/adapters/codex.js +144 -2
  3. package/src/runner.js +258 -0
  4. package/src/store.js +6 -0
  5. package/src/terminal-session.js +12 -1
  6. package/node_modules/node-addon-api/LICENSE.md +0 -9
  7. package/node_modules/node-addon-api/README.md +0 -319
  8. package/node_modules/node-addon-api/common.gypi +0 -20
  9. package/node_modules/node-addon-api/except.gypi +0 -25
  10. package/node_modules/node-addon-api/index.js +0 -12
  11. package/node_modules/node-addon-api/napi-inl.deprecated.h +0 -186
  12. package/node_modules/node-addon-api/napi-inl.h +0 -6607
  13. package/node_modules/node-addon-api/napi.h +0 -3201
  14. package/node_modules/node-addon-api/node_addon_api.gyp +0 -32
  15. package/node_modules/node-addon-api/node_api.gyp +0 -9
  16. package/node_modules/node-addon-api/noexcept.gypi +0 -26
  17. package/node_modules/node-addon-api/nothing.c +0 -0
  18. package/node_modules/node-addon-api/package-support.json +0 -21
  19. package/node_modules/node-addon-api/package.json +0 -480
  20. package/node_modules/node-addon-api/tools/README.md +0 -73
  21. package/node_modules/node-addon-api/tools/check-napi.js +0 -99
  22. package/node_modules/node-addon-api/tools/clang-format.js +0 -71
  23. package/node_modules/node-addon-api/tools/conversion.js +0 -301
  24. package/node_modules/node-addon-api/tools/eslint-format.js +0 -79
  25. package/node_modules/node-pty/LICENSE +0 -69
  26. package/node_modules/node-pty/README.md +0 -165
  27. package/node_modules/node-pty/binding.gyp +0 -111
  28. package/node_modules/node-pty/build/Makefile +0 -369
  29. package/node_modules/node-pty/build/Release/pty.node +0 -0
  30. package/node_modules/node-pty/build/binding.Makefile +0 -6
  31. package/node_modules/node-pty/build/config.gypi +0 -503
  32. package/node_modules/node-pty/build/pty.target.mk +0 -168
  33. package/node_modules/node-pty/deps/.editorconfig +0 -2
  34. package/node_modules/node-pty/deps/winpty/.drone.yml +0 -17
  35. package/node_modules/node-pty/deps/winpty/.gitattributes +0 -19
  36. package/node_modules/node-pty/deps/winpty/LICENSE +0 -21
  37. package/node_modules/node-pty/deps/winpty/Makefile +0 -166
  38. package/node_modules/node-pty/deps/winpty/README.md +0 -151
  39. package/node_modules/node-pty/deps/winpty/RELEASES.md +0 -280
  40. package/node_modules/node-pty/deps/winpty/VERSION.txt +0 -1
  41. package/node_modules/node-pty/deps/winpty/configure +0 -167
  42. package/node_modules/node-pty/deps/winpty/misc/BufferResizeTests.cc +0 -90
  43. package/node_modules/node-pty/deps/winpty/misc/ChangeScreenBuffer.cc +0 -53
  44. package/node_modules/node-pty/deps/winpty/misc/ClearConsole.cc +0 -72
  45. package/node_modules/node-pty/deps/winpty/misc/ConinMode.cc +0 -117
  46. package/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +0 -116
  47. package/node_modules/node-pty/deps/winpty/misc/ConoutMode.cc +0 -113
  48. package/node_modules/node-pty/deps/winpty/misc/DebugClient.py +0 -42
  49. package/node_modules/node-pty/deps/winpty/misc/DebugServer.py +0 -63
  50. package/node_modules/node-pty/deps/winpty/misc/DumpLines.py +0 -5
  51. package/node_modules/node-pty/deps/winpty/misc/EnableExtendedFlags.txt +0 -46
  52. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +0 -528
  53. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +0 -633
  54. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP932.txt +0 -630
  55. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP936.txt +0 -630
  56. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP949.txt +0 -630
  57. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP950.txt +0 -630
  58. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +0 -16
  59. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Results.txt +0 -4
  60. package/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +0 -144
  61. package/node_modules/node-pty/deps/winpty/misc/FontSurvey.cc +0 -100
  62. package/node_modules/node-pty/deps/winpty/misc/FormatChar.h +0 -21
  63. package/node_modules/node-pty/deps/winpty/misc/FreezePerfTest.cc +0 -62
  64. package/node_modules/node-pty/deps/winpty/misc/GetCh.cc +0 -20
  65. package/node_modules/node-pty/deps/winpty/misc/GetConsolePos.cc +0 -41
  66. package/node_modules/node-pty/deps/winpty/misc/GetFont.cc +0 -261
  67. package/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +0 -51
  68. package/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc +0 -87
  69. package/node_modules/node-pty/deps/winpty/misc/MouseInputNotes.txt +0 -90
  70. package/node_modules/node-pty/deps/winpty/misc/MoveConsoleWindow.cc +0 -34
  71. package/node_modules/node-pty/deps/winpty/misc/Notes.txt +0 -219
  72. package/node_modules/node-pty/deps/winpty/misc/OSVersion.cc +0 -27
  73. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferFreezeInactive.cc +0 -101
  74. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest.cc +0 -671
  75. package/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest2.cc +0 -151
  76. package/node_modules/node-pty/deps/winpty/misc/SelectAllTest.cc +0 -45
  77. package/node_modules/node-pty/deps/winpty/misc/SetBufferSize.cc +0 -32
  78. package/node_modules/node-pty/deps/winpty/misc/SetCursorPos.cc +0 -10
  79. package/node_modules/node-pty/deps/winpty/misc/SetFont.cc +0 -145
  80. package/node_modules/node-pty/deps/winpty/misc/SetWindowRect.cc +0 -36
  81. package/node_modules/node-pty/deps/winpty/misc/ShowArgv.cc +0 -12
  82. package/node_modules/node-pty/deps/winpty/misc/ShowConsoleInput.cc +0 -40
  83. package/node_modules/node-pty/deps/winpty/misc/Spew.py +0 -5
  84. package/node_modules/node-pty/deps/winpty/misc/TestUtil.cc +0 -172
  85. package/node_modules/node-pty/deps/winpty/misc/UnicodeDoubleWidthTest.cc +0 -102
  86. package/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest1.cc +0 -246
  87. package/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest2.cc +0 -130
  88. package/node_modules/node-pty/deps/winpty/misc/UnixEcho.cc +0 -89
  89. package/node_modules/node-pty/deps/winpty/misc/Utf16Echo.cc +0 -46
  90. package/node_modules/node-pty/deps/winpty/misc/VeryLargeRead.cc +0 -122
  91. package/node_modules/node-pty/deps/winpty/misc/VkEscapeTest.cc +0 -56
  92. package/node_modules/node-pty/deps/winpty/misc/Win10ResizeWhileFrozen.cc +0 -52
  93. package/node_modules/node-pty/deps/winpty/misc/Win10WrapTest1.cc +0 -57
  94. package/node_modules/node-pty/deps/winpty/misc/Win10WrapTest2.cc +0 -30
  95. package/node_modules/node-pty/deps/winpty/misc/Win32Echo1.cc +0 -26
  96. package/node_modules/node-pty/deps/winpty/misc/Win32Echo2.cc +0 -19
  97. package/node_modules/node-pty/deps/winpty/misc/Win32Test1.cc +0 -46
  98. package/node_modules/node-pty/deps/winpty/misc/Win32Test2.cc +0 -70
  99. package/node_modules/node-pty/deps/winpty/misc/Win32Test3.cc +0 -78
  100. package/node_modules/node-pty/deps/winpty/misc/Win32Write1.cc +0 -44
  101. package/node_modules/node-pty/deps/winpty/misc/WindowsBugCrashReader.cc +0 -27
  102. package/node_modules/node-pty/deps/winpty/misc/WriteConsole.cc +0 -106
  103. package/node_modules/node-pty/deps/winpty/misc/build32.sh +0 -9
  104. package/node_modules/node-pty/deps/winpty/misc/build64.sh +0 -9
  105. package/node_modules/node-pty/deps/winpty/misc/color-test.sh +0 -212
  106. package/node_modules/node-pty/deps/winpty/misc/font-notes.txt +0 -300
  107. package/node_modules/node-pty/deps/winpty/misc/winbug-15048.cc +0 -201
  108. package/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +0 -36
  109. package/node_modules/node-pty/deps/winpty/ship/common_ship.py +0 -53
  110. package/node_modules/node-pty/deps/winpty/ship/make_msvc_package.py +0 -165
  111. package/node_modules/node-pty/deps/winpty/ship/ship.py +0 -108
  112. package/node_modules/node-pty/deps/winpty/src/agent/Agent.cc +0 -613
  113. package/node_modules/node-pty/deps/winpty/src/agent/Agent.h +0 -103
  114. package/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.cc +0 -84
  115. package/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.h +0 -28
  116. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.cc +0 -632
  117. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.h +0 -28
  118. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.cc +0 -852
  119. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.h +0 -109
  120. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.cc +0 -121
  121. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.h +0 -36
  122. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.cc +0 -152
  123. package/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.h +0 -41
  124. package/node_modules/node-pty/deps/winpty/src/agent/Coord.h +0 -87
  125. package/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.cc +0 -239
  126. package/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.h +0 -32
  127. package/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.cc +0 -422
  128. package/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.h +0 -28
  129. package/node_modules/node-pty/deps/winpty/src/agent/DsrSender.h +0 -30
  130. package/node_modules/node-pty/deps/winpty/src/agent/EventLoop.cc +0 -99
  131. package/node_modules/node-pty/deps/winpty/src/agent/EventLoop.h +0 -47
  132. package/node_modules/node-pty/deps/winpty/src/agent/InputMap.cc +0 -246
  133. package/node_modules/node-pty/deps/winpty/src/agent/InputMap.h +0 -114
  134. package/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.cc +0 -71
  135. package/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.h +0 -68
  136. package/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.cc +0 -378
  137. package/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.h +0 -125
  138. package/node_modules/node-pty/deps/winpty/src/agent/Scraper.cc +0 -699
  139. package/node_modules/node-pty/deps/winpty/src/agent/Scraper.h +0 -103
  140. package/node_modules/node-pty/deps/winpty/src/agent/SimplePool.h +0 -75
  141. package/node_modules/node-pty/deps/winpty/src/agent/SmallRect.h +0 -143
  142. package/node_modules/node-pty/deps/winpty/src/agent/Terminal.cc +0 -535
  143. package/node_modules/node-pty/deps/winpty/src/agent/Terminal.h +0 -69
  144. package/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncoding.h +0 -157
  145. package/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncodingTest.cc +0 -189
  146. package/node_modules/node-pty/deps/winpty/src/agent/Win32Console.cc +0 -107
  147. package/node_modules/node-pty/deps/winpty/src/agent/Win32Console.h +0 -67
  148. package/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.cc +0 -193
  149. package/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.h +0 -99
  150. package/node_modules/node-pty/deps/winpty/src/agent/main.cc +0 -114
  151. package/node_modules/node-pty/deps/winpty/src/agent/subdir.mk +0 -61
  152. package/node_modules/node-pty/deps/winpty/src/configurations.gypi +0 -60
  153. package/node_modules/node-pty/deps/winpty/src/debugserver/DebugServer.cc +0 -117
  154. package/node_modules/node-pty/deps/winpty/src/debugserver/subdir.mk +0 -41
  155. package/node_modules/node-pty/deps/winpty/src/include/winpty.h +0 -242
  156. package/node_modules/node-pty/deps/winpty/src/include/winpty_constants.h +0 -131
  157. package/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.cc +0 -75
  158. package/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.h +0 -28
  159. package/node_modules/node-pty/deps/winpty/src/libwinpty/LibWinptyException.h +0 -54
  160. package/node_modules/node-pty/deps/winpty/src/libwinpty/WinptyInternal.h +0 -72
  161. package/node_modules/node-pty/deps/winpty/src/libwinpty/subdir.mk +0 -46
  162. package/node_modules/node-pty/deps/winpty/src/libwinpty/winpty.cc +0 -970
  163. package/node_modules/node-pty/deps/winpty/src/shared/AgentMsg.h +0 -38
  164. package/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.cc +0 -122
  165. package/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.h +0 -73
  166. package/node_modules/node-pty/deps/winpty/src/shared/Buffer.cc +0 -103
  167. package/node_modules/node-pty/deps/winpty/src/shared/Buffer.h +0 -102
  168. package/node_modules/node-pty/deps/winpty/src/shared/DebugClient.cc +0 -187
  169. package/node_modules/node-pty/deps/winpty/src/shared/DebugClient.h +0 -38
  170. package/node_modules/node-pty/deps/winpty/src/shared/GenRandom.cc +0 -138
  171. package/node_modules/node-pty/deps/winpty/src/shared/GenRandom.h +0 -55
  172. package/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +0 -13
  173. package/node_modules/node-pty/deps/winpty/src/shared/Mutex.h +0 -54
  174. package/node_modules/node-pty/deps/winpty/src/shared/OsModule.h +0 -63
  175. package/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.cc +0 -36
  176. package/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.h +0 -45
  177. package/node_modules/node-pty/deps/winpty/src/shared/PrecompiledHeader.h +0 -43
  178. package/node_modules/node-pty/deps/winpty/src/shared/StringBuilder.h +0 -227
  179. package/node_modules/node-pty/deps/winpty/src/shared/StringBuilderTest.cc +0 -114
  180. package/node_modules/node-pty/deps/winpty/src/shared/StringUtil.cc +0 -55
  181. package/node_modules/node-pty/deps/winpty/src/shared/StringUtil.h +0 -80
  182. package/node_modules/node-pty/deps/winpty/src/shared/TimeMeasurement.h +0 -63
  183. package/node_modules/node-pty/deps/winpty/src/shared/UnixCtrlChars.h +0 -45
  184. package/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +0 -20
  185. package/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.cc +0 -460
  186. package/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.h +0 -104
  187. package/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.cc +0 -252
  188. package/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.h +0 -29
  189. package/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.cc +0 -55
  190. package/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.h +0 -64
  191. package/node_modules/node-pty/deps/winpty/src/shared/WinptyException.cc +0 -57
  192. package/node_modules/node-pty/deps/winpty/src/shared/WinptyException.h +0 -43
  193. package/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.cc +0 -42
  194. package/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.h +0 -27
  195. package/node_modules/node-pty/deps/winpty/src/shared/winpty_snprintf.h +0 -99
  196. package/node_modules/node-pty/deps/winpty/src/subdir.mk +0 -5
  197. package/node_modules/node-pty/deps/winpty/src/tests/subdir.mk +0 -28
  198. package/node_modules/node-pty/deps/winpty/src/tests/trivial_test.cc +0 -158
  199. package/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.cc +0 -114
  200. package/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.h +0 -56
  201. package/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.cc +0 -80
  202. package/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.h +0 -53
  203. package/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.cc +0 -86
  204. package/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.h +0 -31
  205. package/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.cc +0 -70
  206. package/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.h +0 -42
  207. package/node_modules/node-pty/deps/winpty/src/unix-adapter/main.cc +0 -729
  208. package/node_modules/node-pty/deps/winpty/src/unix-adapter/subdir.mk +0 -41
  209. package/node_modules/node-pty/deps/winpty/src/winpty.gyp +0 -234
  210. package/node_modules/node-pty/deps/winpty/vcbuild.bat +0 -83
  211. package/node_modules/node-pty/lib/conpty_console_list_agent.js +0 -16
  212. package/node_modules/node-pty/lib/conpty_console_list_agent.js.map +0 -1
  213. package/node_modules/node-pty/lib/eventEmitter2.js +0 -47
  214. package/node_modules/node-pty/lib/eventEmitter2.js.map +0 -1
  215. package/node_modules/node-pty/lib/eventEmitter2.test.js +0 -30
  216. package/node_modules/node-pty/lib/eventEmitter2.test.js.map +0 -1
  217. package/node_modules/node-pty/lib/index.js +0 -52
  218. package/node_modules/node-pty/lib/index.js.map +0 -1
  219. package/node_modules/node-pty/lib/interfaces.js +0 -7
  220. package/node_modules/node-pty/lib/interfaces.js.map +0 -1
  221. package/node_modules/node-pty/lib/shared/conout.js +0 -11
  222. package/node_modules/node-pty/lib/shared/conout.js.map +0 -1
  223. package/node_modules/node-pty/lib/terminal.js +0 -190
  224. package/node_modules/node-pty/lib/terminal.js.map +0 -1
  225. package/node_modules/node-pty/lib/terminal.test.js +0 -139
  226. package/node_modules/node-pty/lib/terminal.test.js.map +0 -1
  227. package/node_modules/node-pty/lib/testUtils.test.js +0 -28
  228. package/node_modules/node-pty/lib/testUtils.test.js.map +0 -1
  229. package/node_modules/node-pty/lib/types.js +0 -7
  230. package/node_modules/node-pty/lib/types.js.map +0 -1
  231. package/node_modules/node-pty/lib/unixTerminal.js +0 -346
  232. package/node_modules/node-pty/lib/unixTerminal.js.map +0 -1
  233. package/node_modules/node-pty/lib/unixTerminal.test.js +0 -351
  234. package/node_modules/node-pty/lib/unixTerminal.test.js.map +0 -1
  235. package/node_modules/node-pty/lib/utils.js +0 -39
  236. package/node_modules/node-pty/lib/utils.js.map +0 -1
  237. package/node_modules/node-pty/lib/windowsConoutConnection.js +0 -125
  238. package/node_modules/node-pty/lib/windowsConoutConnection.js.map +0 -1
  239. package/node_modules/node-pty/lib/windowsPtyAgent.js +0 -320
  240. package/node_modules/node-pty/lib/windowsPtyAgent.js.map +0 -1
  241. package/node_modules/node-pty/lib/windowsPtyAgent.test.js +0 -90
  242. package/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +0 -1
  243. package/node_modules/node-pty/lib/windowsTerminal.js +0 -199
  244. package/node_modules/node-pty/lib/windowsTerminal.js.map +0 -1
  245. package/node_modules/node-pty/lib/windowsTerminal.test.js +0 -219
  246. package/node_modules/node-pty/lib/windowsTerminal.test.js.map +0 -1
  247. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js +0 -22
  248. package/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +0 -1
  249. package/node_modules/node-pty/node-addon-api/node_addon_api.Makefile +0 -6
  250. package/node_modules/node-pty/node-addon-api/node_addon_api.target.mk +0 -106
  251. package/node_modules/node-pty/node-addon-api/node_addon_api_except.target.mk +0 -110
  252. package/node_modules/node-pty/node-addon-api/node_addon_api_maybe.target.mk +0 -106
  253. package/node_modules/node-pty/package.json +0 -64
  254. package/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  255. package/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  256. package/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  257. package/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  258. package/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  259. package/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  260. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
  261. package/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
  262. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  263. package/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  264. package/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
  265. package/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
  266. package/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  267. package/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  268. package/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
  269. package/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
  270. package/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  271. package/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  272. package/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
  273. package/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
  274. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
  275. package/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  276. package/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
  277. package/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
  278. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
  279. package/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  280. package/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
  281. package/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
  282. package/node_modules/node-pty/scripts/gen-compile-commands.js +0 -8
  283. package/node_modules/node-pty/scripts/increment-version.js +0 -54
  284. package/node_modules/node-pty/scripts/post-install.js +0 -80
  285. package/node_modules/node-pty/scripts/prebuild.js +0 -34
  286. package/node_modules/node-pty/src/conpty_console_list_agent.ts +0 -15
  287. package/node_modules/node-pty/src/eventEmitter2.test.ts +0 -30
  288. package/node_modules/node-pty/src/eventEmitter2.ts +0 -48
  289. package/node_modules/node-pty/src/index.ts +0 -52
  290. package/node_modules/node-pty/src/interfaces.ts +0 -130
  291. package/node_modules/node-pty/src/native.d.ts +0 -54
  292. package/node_modules/node-pty/src/shared/conout.ts +0 -15
  293. package/node_modules/node-pty/src/terminal.test.ts +0 -119
  294. package/node_modules/node-pty/src/terminal.ts +0 -211
  295. package/node_modules/node-pty/src/testUtils.test.ts +0 -23
  296. package/node_modules/node-pty/src/tsconfig.json +0 -22
  297. package/node_modules/node-pty/src/types.ts +0 -15
  298. package/node_modules/node-pty/src/unix/pty.cc +0 -799
  299. package/node_modules/node-pty/src/unix/spawn-helper.cc +0 -23
  300. package/node_modules/node-pty/src/unixTerminal.test.ts +0 -367
  301. package/node_modules/node-pty/src/unixTerminal.ts +0 -388
  302. package/node_modules/node-pty/src/utils.ts +0 -29
  303. package/node_modules/node-pty/src/win/conpty.cc +0 -583
  304. package/node_modules/node-pty/src/win/conpty.h +0 -41
  305. package/node_modules/node-pty/src/win/conpty_console_list.cc +0 -44
  306. package/node_modules/node-pty/src/win/path_util.cc +0 -95
  307. package/node_modules/node-pty/src/win/path_util.h +0 -26
  308. package/node_modules/node-pty/src/win/winpty.cc +0 -333
  309. package/node_modules/node-pty/src/windowsConoutConnection.ts +0 -82
  310. package/node_modules/node-pty/src/windowsPtyAgent.test.ts +0 -94
  311. package/node_modules/node-pty/src/windowsPtyAgent.ts +0 -321
  312. package/node_modules/node-pty/src/windowsTerminal.test.ts +0 -229
  313. package/node_modules/node-pty/src/windowsTerminal.ts +0 -203
  314. package/node_modules/node-pty/src/worker/conoutSocketWorker.ts +0 -22
  315. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  316. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
  317. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  318. package/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
  319. package/node_modules/node-pty/typings/node-pty.d.ts +0 -211
@@ -1,799 +0,0 @@
1
- /**
2
- * Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
3
- * Copyright (c) 2017, Daniel Imms (MIT License)
4
- *
5
- * pty.cc:
6
- * This file is responsible for starting processes
7
- * with pseudo-terminal file descriptors.
8
- *
9
- * See:
10
- * man pty
11
- * man tty_ioctl
12
- * man termios
13
- * man forkpty
14
- */
15
-
16
- /**
17
- * Includes
18
- */
19
-
20
- #define NODE_ADDON_API_DISABLE_DEPRECATED
21
- #include <napi.h>
22
- #include <assert.h>
23
- #include <errno.h>
24
- #include <string.h>
25
- #include <stdlib.h>
26
- #include <unistd.h>
27
- #include <thread>
28
-
29
- #include <sys/types.h>
30
- #include <sys/stat.h>
31
- #include <sys/ioctl.h>
32
- #include <sys/wait.h>
33
- #include <fcntl.h>
34
- #include <signal.h>
35
-
36
- /* forkpty */
37
- /* http://www.gnu.org/software/gnulib/manual/html_node/forkpty.html */
38
- #if defined(__linux__)
39
- #include <pty.h>
40
- #elif defined(__APPLE__)
41
- #include <util.h>
42
- #elif defined(__FreeBSD__)
43
- #include <libutil.h>
44
- #include <termios.h>
45
- #elif defined(__OpenBSD__)
46
- #include <util.h>
47
- #include <termios.h>
48
- #endif
49
-
50
- /* Some platforms name VWERASE and VDISCARD differently */
51
- #if !defined(VWERASE) && defined(VWERSE)
52
- #define VWERASE VWERSE
53
- #endif
54
- #if !defined(VDISCARD) && defined(VDISCRD)
55
- #define VDISCARD VDISCRD
56
- #endif
57
-
58
- /* for pty_getproc */
59
- #if defined(__linux__)
60
- #include <stdio.h>
61
- #include <stdint.h>
62
- #elif defined(__APPLE__)
63
- #include <libproc.h>
64
- #include <os/availability.h>
65
- #include <paths.h>
66
- #include <spawn.h>
67
- #include <sys/event.h>
68
- #include <sys/sysctl.h>
69
- #include <termios.h>
70
- #endif
71
-
72
- /* NSIG - macro for highest signal + 1, should be defined */
73
- #ifndef NSIG
74
- #define NSIG 32
75
- #endif
76
-
77
- /* macOS 10.14 back does not define this constant */
78
- #ifndef POSIX_SPAWN_SETSID
79
- #define POSIX_SPAWN_SETSID 1024
80
- #endif
81
-
82
- /* environ for execvpe */
83
- /* node/src/node_child_process.cc */
84
- #if !defined(__APPLE__)
85
- extern char **environ;
86
- #endif
87
-
88
- #if defined(__APPLE__)
89
- extern "C" {
90
- // Changes the current thread's directory to a path or directory file
91
- // descriptor. libpthread only exposes a syscall wrapper starting in
92
- // macOS 10.12, but the system call dates back to macOS 10.5. On older OSes,
93
- // the syscall is issued directly.
94
- int pthread_chdir_np(const char* dir) API_AVAILABLE(macosx(10.12));
95
- int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));
96
- }
97
-
98
- #define HANDLE_EINTR(x) ({ \
99
- int eintr_wrapper_counter = 0; \
100
- decltype(x) eintr_wrapper_result; \
101
- do { \
102
- eintr_wrapper_result = (x); \
103
- } while (eintr_wrapper_result == -1 && errno == EINTR && \
104
- eintr_wrapper_counter++ < 100); \
105
- eintr_wrapper_result; \
106
- })
107
- #endif
108
-
109
- struct ExitEvent {
110
- int exit_code = 0, signal_code = 0;
111
- };
112
-
113
- void SetupExitCallback(Napi::Env env, Napi::Function cb, pid_t pid) {
114
- std::thread *th = new std::thread;
115
- // Don't use Napi::AsyncWorker which is limited by UV_THREADPOOL_SIZE.
116
- auto tsfn = Napi::ThreadSafeFunction::New(
117
- env,
118
- cb, // JavaScript function called asynchronously
119
- "SetupExitCallback_resource", // Name
120
- 0, // Unlimited queue
121
- 1, // Only one thread will use this initially
122
- [th](Napi::Env) { // Finalizer used to clean threads up
123
- th->join();
124
- delete th;
125
- });
126
- *th = std::thread([tsfn = std::move(tsfn), pid] {
127
- auto callback = [](Napi::Env env, Napi::Function cb, ExitEvent *exit_event) {
128
- cb.Call({Napi::Number::New(env, exit_event->exit_code),
129
- Napi::Number::New(env, exit_event->signal_code)});
130
- delete exit_event;
131
- };
132
-
133
- int ret;
134
- int stat_loc;
135
- #if defined(__APPLE__)
136
- // Based on
137
- // https://source.chromium.org/chromium/chromium/src/+/main:base/process/kill_mac.cc;l=35-69?
138
- int kq = HANDLE_EINTR(kqueue());
139
- struct kevent change = {0};
140
- EV_SET(&change, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
141
- ret = HANDLE_EINTR(kevent(kq, &change, 1, NULL, 0, NULL));
142
- if (ret == -1) {
143
- if (errno == ESRCH) {
144
- // At this point, one of the following has occurred:
145
- // 1. The process has died but has not yet been reaped.
146
- // 2. The process has died and has already been reaped.
147
- // 3. The process is in the process of dying. It's no longer
148
- // kqueueable, but it may not be waitable yet either. Mark calls
149
- // this case the "zombie death race".
150
- ret = HANDLE_EINTR(waitpid(pid, &stat_loc, WNOHANG));
151
- if (ret == 0) {
152
- ret = kill(pid, SIGKILL);
153
- if (ret != -1) {
154
- HANDLE_EINTR(waitpid(pid, &stat_loc, 0));
155
- }
156
- }
157
- }
158
- } else {
159
- struct kevent event = {0};
160
- ret = HANDLE_EINTR(kevent(kq, NULL, 0, &event, 1, NULL));
161
- if (ret == 1) {
162
- if ((event.fflags & NOTE_EXIT) &&
163
- (event.ident == static_cast<uintptr_t>(pid))) {
164
- // The process is dead or dying. This won't block for long, if at
165
- // all.
166
- HANDLE_EINTR(waitpid(pid, &stat_loc, 0));
167
- }
168
- }
169
- }
170
- #else
171
- while (true) {
172
- errno = 0;
173
- if ((ret = waitpid(pid, &stat_loc, 0)) != pid) {
174
- if (ret == -1 && errno == EINTR) {
175
- continue;
176
- }
177
- if (ret == -1 && errno == ECHILD) {
178
- // XXX node v0.8.x seems to have this problem.
179
- // waitpid is already handled elsewhere.
180
- ;
181
- } else {
182
- assert(false);
183
- }
184
- }
185
- break;
186
- }
187
- #endif
188
- ExitEvent *exit_event = new ExitEvent;
189
- if (WIFEXITED(stat_loc)) {
190
- exit_event->exit_code = WEXITSTATUS(stat_loc); // errno?
191
- }
192
- if (WIFSIGNALED(stat_loc)) {
193
- exit_event->signal_code = WTERMSIG(stat_loc);
194
- }
195
- auto status = tsfn.BlockingCall(exit_event, callback); // In main thread
196
- switch (status) {
197
- case napi_closing:
198
- break;
199
-
200
- case napi_queue_full:
201
- Napi::Error::Fatal("SetupExitCallback", "Queue was full");
202
-
203
- case napi_ok:
204
- if (tsfn.Release() != napi_ok) {
205
- Napi::Error::Fatal("SetupExitCallback", "ThreadSafeFunction.Release() failed");
206
- }
207
- break;
208
-
209
- default:
210
- Napi::Error::Fatal("SetupExitCallback", "ThreadSafeFunction.BlockingCall() failed");
211
- }
212
- });
213
- }
214
-
215
- /**
216
- * Methods
217
- */
218
-
219
- Napi::Value PtyFork(const Napi::CallbackInfo& info);
220
- Napi::Value PtyOpen(const Napi::CallbackInfo& info);
221
- Napi::Value PtyResize(const Napi::CallbackInfo& info);
222
- Napi::Value PtyGetProc(const Napi::CallbackInfo& info);
223
-
224
- /**
225
- * Functions
226
- */
227
-
228
- static int
229
- pty_nonblock(int);
230
-
231
- #if defined(__APPLE__)
232
- static char *
233
- pty_getproc(int);
234
- #else
235
- static char *
236
- pty_getproc(int, char *);
237
- #endif
238
-
239
- #if defined(__APPLE__) || defined(__OpenBSD__)
240
- static void
241
- pty_posix_spawn(char** argv, char** env,
242
- const struct termios *termp,
243
- const struct winsize *winp,
244
- int* master,
245
- pid_t* pid,
246
- int* err);
247
- #endif
248
-
249
- struct DelBuf {
250
- int len;
251
- DelBuf(int len) : len(len) {}
252
- void operator()(char **p) {
253
- if (p == nullptr)
254
- return;
255
- for (int i = 0; i < len; i++)
256
- free(p[i]);
257
- delete[] p;
258
- }
259
- };
260
-
261
- Napi::Value PtyFork(const Napi::CallbackInfo& info) {
262
- Napi::Env napiEnv(info.Env());
263
- Napi::HandleScope scope(napiEnv);
264
-
265
- if (info.Length() != 11 ||
266
- !info[0].IsString() ||
267
- !info[1].IsArray() ||
268
- !info[2].IsArray() ||
269
- !info[3].IsString() ||
270
- !info[4].IsNumber() ||
271
- !info[5].IsNumber() ||
272
- !info[6].IsNumber() ||
273
- !info[7].IsNumber() ||
274
- !info[8].IsBoolean() ||
275
- !info[9].IsString() ||
276
- !info[10].IsFunction()) {
277
- throw Napi::Error::New(napiEnv, "Usage: pty.fork(file, args, env, cwd, cols, rows, uid, gid, utf8, helperPath, onexit)");
278
- }
279
-
280
- // file
281
- std::string file = info[0].As<Napi::String>();
282
-
283
- // args
284
- Napi::Array argv_ = info[1].As<Napi::Array>();
285
-
286
- // env
287
- Napi::Array env_ = info[2].As<Napi::Array>();
288
- int envc = env_.Length();
289
- std::unique_ptr<char *, DelBuf> env_unique_ptr(new char *[envc + 1], DelBuf(envc + 1));
290
- char **env = env_unique_ptr.get();
291
- env[envc] = NULL;
292
- for (int i = 0; i < envc; i++) {
293
- std::string pair = env_.Get(i).As<Napi::String>();
294
- env[i] = strdup(pair.c_str());
295
- }
296
-
297
- // cwd
298
- std::string cwd_ = info[3].As<Napi::String>();
299
-
300
- // size
301
- struct winsize winp;
302
- winp.ws_col = info[4].As<Napi::Number>().Int32Value();
303
- winp.ws_row = info[5].As<Napi::Number>().Int32Value();
304
- winp.ws_xpixel = 0;
305
- winp.ws_ypixel = 0;
306
-
307
- #if !defined(__APPLE__)
308
- // uid / gid
309
- int uid = info[6].As<Napi::Number>().Int32Value();
310
- int gid = info[7].As<Napi::Number>().Int32Value();
311
- #endif
312
-
313
- // termios
314
- struct termios t = termios();
315
- struct termios *term = &t;
316
- term->c_iflag = ICRNL | IXON | IXANY | IMAXBEL | BRKINT;
317
- if (info[8].As<Napi::Boolean>().Value()) {
318
- #if defined(IUTF8)
319
- term->c_iflag |= IUTF8;
320
- #endif
321
- }
322
- term->c_oflag = OPOST | ONLCR;
323
- term->c_cflag = CREAD | CS8 | HUPCL;
324
- term->c_lflag = ICANON | ISIG | IEXTEN | ECHO | ECHOE | ECHOK | ECHOKE | ECHOCTL;
325
-
326
- term->c_cc[VEOF] = 4;
327
- term->c_cc[VEOL] = -1;
328
- term->c_cc[VEOL2] = -1;
329
- term->c_cc[VERASE] = 0x7f;
330
- term->c_cc[VWERASE] = 23;
331
- term->c_cc[VKILL] = 21;
332
- term->c_cc[VREPRINT] = 18;
333
- term->c_cc[VINTR] = 3;
334
- term->c_cc[VQUIT] = 0x1c;
335
- term->c_cc[VSUSP] = 26;
336
- term->c_cc[VSTART] = 17;
337
- term->c_cc[VSTOP] = 19;
338
- term->c_cc[VLNEXT] = 22;
339
- term->c_cc[VDISCARD] = 15;
340
- term->c_cc[VMIN] = 1;
341
- term->c_cc[VTIME] = 0;
342
-
343
- #if (__APPLE__)
344
- term->c_cc[VDSUSP] = 25;
345
- term->c_cc[VSTATUS] = 20;
346
- #endif
347
-
348
- cfsetispeed(term, B38400);
349
- cfsetospeed(term, B38400);
350
-
351
- // helperPath
352
- std::string helper_path = info[9].As<Napi::String>();
353
-
354
- pid_t pid;
355
- int master;
356
- #if defined(__APPLE__)
357
- int argc = argv_.Length();
358
- int argl = argc + 4;
359
- std::unique_ptr<char *, DelBuf> argv_unique_ptr(new char *[argl], DelBuf(argl));
360
- char **argv = argv_unique_ptr.get();
361
- argv[0] = strdup(helper_path.c_str());
362
- argv[1] = strdup(cwd_.c_str());
363
- argv[2] = strdup(file.c_str());
364
- argv[argl - 1] = NULL;
365
- for (int i = 0; i < argc; i++) {
366
- std::string arg = argv_.Get(i).As<Napi::String>();
367
- argv[i + 3] = strdup(arg.c_str());
368
- }
369
-
370
- int err = -1;
371
- pty_posix_spawn(argv, env, term, &winp, &master, &pid, &err);
372
- if (err != 0) {
373
- throw Napi::Error::New(napiEnv, "posix_spawnp failed.");
374
- }
375
- if (pty_nonblock(master) == -1) {
376
- throw Napi::Error::New(napiEnv, "Could not set master fd to nonblocking.");
377
- }
378
- #else
379
- int argc = argv_.Length();
380
- int argl = argc + 2;
381
- std::unique_ptr<char *, DelBuf> argv_unique_ptr(new char *[argl], DelBuf(argl));
382
- char** argv = argv_unique_ptr.get();
383
- argv[0] = strdup(file.c_str());
384
- argv[argl - 1] = NULL;
385
- for (int i = 0; i < argc; i++) {
386
- std::string arg = argv_.Get(i).As<Napi::String>();
387
- argv[i + 1] = strdup(arg.c_str());
388
- }
389
-
390
- sigset_t newmask, oldmask;
391
- struct sigaction sig_action;
392
- // temporarily block all signals
393
- // this is needed due to a race condition in openpty
394
- // and to avoid running signal handlers in the child
395
- // before exec* happened
396
- sigfillset(&newmask);
397
- pthread_sigmask(SIG_SETMASK, &newmask, &oldmask);
398
-
399
- pid = forkpty(&master, nullptr, static_cast<termios*>(term), static_cast<winsize*>(&winp));
400
-
401
- if (!pid) {
402
- // remove all signal handler from child
403
- sig_action.sa_handler = SIG_DFL;
404
- sig_action.sa_flags = 0;
405
- sigemptyset(&sig_action.sa_mask);
406
- for (int i = 0 ; i < NSIG ; i++) { // NSIG is a macro for all signals + 1
407
- sigaction(i, &sig_action, NULL);
408
- }
409
- }
410
-
411
- // reenable signals
412
- pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
413
-
414
- switch (pid) {
415
- case -1:
416
- throw Napi::Error::New(napiEnv, "forkpty(3) failed.");
417
- case 0:
418
- if (strlen(cwd_.c_str())) {
419
- if (chdir(cwd_.c_str()) == -1) {
420
- perror("chdir(2) failed.");
421
- _exit(1);
422
- }
423
- }
424
-
425
- if (uid != -1 && gid != -1) {
426
- if (setgid(gid) == -1) {
427
- perror("setgid(2) failed.");
428
- _exit(1);
429
- }
430
- if (setuid(uid) == -1) {
431
- perror("setuid(2) failed.");
432
- _exit(1);
433
- }
434
- }
435
-
436
- {
437
- char **old = environ;
438
- environ = env;
439
- execvp(argv[0], argv);
440
- environ = old;
441
- perror("execvp(3) failed.");
442
- _exit(1);
443
- }
444
- default:
445
- if (pty_nonblock(master) == -1) {
446
- throw Napi::Error::New(napiEnv, "Could not set master fd to nonblocking.");
447
- }
448
- }
449
- #endif
450
-
451
- Napi::Object obj = Napi::Object::New(napiEnv);
452
- obj.Set("fd", Napi::Number::New(napiEnv, master));
453
- obj.Set("pid", Napi::Number::New(napiEnv, pid));
454
- obj.Set("pty", Napi::String::New(napiEnv, ptsname(master)));
455
-
456
- // Set up process exit callback.
457
- Napi::Function cb = info[10].As<Napi::Function>();
458
- SetupExitCallback(napiEnv, cb, pid);
459
- return obj;
460
- }
461
-
462
- Napi::Value PtyOpen(const Napi::CallbackInfo& info) {
463
- Napi::Env env(info.Env());
464
- Napi::HandleScope scope(env);
465
-
466
- if (info.Length() != 2 ||
467
- !info[0].IsNumber() ||
468
- !info[1].IsNumber()) {
469
- throw Napi::Error::New(env, "Usage: pty.open(cols, rows)");
470
- }
471
-
472
- // size
473
- struct winsize winp;
474
- winp.ws_col = info[0].As<Napi::Number>().Int32Value();
475
- winp.ws_row = info[1].As<Napi::Number>().Int32Value();
476
- winp.ws_xpixel = 0;
477
- winp.ws_ypixel = 0;
478
-
479
- // pty
480
- int master, slave;
481
- int ret = openpty(&master, &slave, nullptr, NULL, static_cast<winsize*>(&winp));
482
-
483
- if (ret == -1) {
484
- throw Napi::Error::New(env, "openpty(3) failed.");
485
- }
486
-
487
- if (pty_nonblock(master) == -1) {
488
- throw Napi::Error::New(env, "Could not set master fd to nonblocking.");
489
- }
490
-
491
- if (pty_nonblock(slave) == -1) {
492
- throw Napi::Error::New(env, "Could not set slave fd to nonblocking.");
493
- }
494
-
495
- Napi::Object obj = Napi::Object::New(env);
496
- obj.Set("master", Napi::Number::New(env, master));
497
- obj.Set("slave", Napi::Number::New(env, slave));
498
- obj.Set("pty", Napi::String::New(env, ptsname(master)));
499
-
500
- return obj;
501
- }
502
-
503
- Napi::Value PtyResize(const Napi::CallbackInfo& info) {
504
- Napi::Env env(info.Env());
505
- Napi::HandleScope scope(env);
506
-
507
- if (info.Length() != 3 ||
508
- !info[0].IsNumber() ||
509
- !info[1].IsNumber() ||
510
- !info[2].IsNumber()) {
511
- throw Napi::Error::New(env, "Usage: pty.resize(fd, cols, rows)");
512
- }
513
-
514
- int fd = info[0].As<Napi::Number>().Int32Value();
515
-
516
- struct winsize winp;
517
- winp.ws_col = info[1].As<Napi::Number>().Int32Value();
518
- winp.ws_row = info[2].As<Napi::Number>().Int32Value();
519
- winp.ws_xpixel = 0;
520
- winp.ws_ypixel = 0;
521
-
522
- if (ioctl(fd, TIOCSWINSZ, &winp) == -1) {
523
- switch (errno) {
524
- case EBADF:
525
- throw Napi::Error::New(env, "ioctl(2) failed, EBADF");
526
- case EFAULT:
527
- throw Napi::Error::New(env, "ioctl(2) failed, EFAULT");
528
- case EINVAL:
529
- throw Napi::Error::New(env, "ioctl(2) failed, EINVAL");
530
- case ENOTTY:
531
- throw Napi::Error::New(env, "ioctl(2) failed, ENOTTY");
532
- }
533
- throw Napi::Error::New(env, "ioctl(2) failed");
534
- }
535
-
536
- return env.Undefined();
537
- }
538
-
539
- /**
540
- * Foreground Process Name
541
- */
542
- Napi::Value PtyGetProc(const Napi::CallbackInfo& info) {
543
- Napi::Env env(info.Env());
544
- Napi::HandleScope scope(env);
545
-
546
- #if defined(__APPLE__)
547
- if (info.Length() != 1 ||
548
- !info[0].IsNumber()) {
549
- throw Napi::Error::New(env, "Usage: pty.process(pid)");
550
- }
551
-
552
- int fd = info[0].As<Napi::Number>().Int32Value();
553
- char *name = pty_getproc(fd);
554
- #else
555
- if (info.Length() != 2 ||
556
- !info[0].IsNumber() ||
557
- !info[1].IsString()) {
558
- throw Napi::Error::New(env, "Usage: pty.process(fd, tty)");
559
- }
560
-
561
- int fd = info[0].As<Napi::Number>().Int32Value();
562
-
563
- std::string tty_ = info[1].As<Napi::String>();
564
- char *tty = strdup(tty_.c_str());
565
- char *name = pty_getproc(fd, tty);
566
- free(tty);
567
- #endif
568
-
569
- if (name == NULL) {
570
- return env.Undefined();
571
- }
572
-
573
- Napi::String name_ = Napi::String::New(env, name);
574
- free(name);
575
- return name_;
576
- }
577
-
578
- /**
579
- * Nonblocking FD
580
- */
581
-
582
- static int
583
- pty_nonblock(int fd) {
584
- int flags = fcntl(fd, F_GETFL, 0);
585
- if (flags == -1) return -1;
586
- return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
587
- }
588
-
589
- /**
590
- * pty_getproc
591
- * Taken from tmux.
592
- */
593
-
594
- // Taken from: tmux (http://tmux.sourceforge.net/)
595
- // Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
596
- // Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
597
- // Copyright (c) 2009 Todd Carson <toc@daybefore.net>
598
- //
599
- // Permission to use, copy, modify, and distribute this software for any
600
- // purpose with or without fee is hereby granted, provided that the above
601
- // copyright notice and this permission notice appear in all copies.
602
- //
603
- // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
604
- // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
605
- // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
606
- // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
607
- // WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
608
- // IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
609
- // OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
610
-
611
- #if defined(__linux__)
612
-
613
- static char *
614
- pty_getproc(int fd, char *tty) {
615
- FILE *f;
616
- char *path, *buf;
617
- size_t len;
618
- int ch;
619
- pid_t pgrp;
620
- int r;
621
-
622
- if ((pgrp = tcgetpgrp(fd)) == -1) {
623
- return NULL;
624
- }
625
-
626
- r = asprintf(&path, "/proc/%lld/cmdline", (long long)pgrp);
627
- if (r == -1 || path == NULL) return NULL;
628
-
629
- if ((f = fopen(path, "r")) == NULL) {
630
- free(path);
631
- return NULL;
632
- }
633
-
634
- free(path);
635
-
636
- len = 0;
637
- buf = NULL;
638
- while ((ch = fgetc(f)) != EOF) {
639
- if (ch == '\0') break;
640
- buf = (char *)realloc(buf, len + 2);
641
- if (buf == NULL) return NULL;
642
- buf[len++] = ch;
643
- }
644
-
645
- if (buf != NULL) {
646
- buf[len] = '\0';
647
- }
648
-
649
- fclose(f);
650
- return buf;
651
- }
652
-
653
- #elif defined(__APPLE__)
654
-
655
- static char *
656
- pty_getproc(int fd) {
657
- int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 };
658
- size_t size;
659
- struct kinfo_proc kp;
660
-
661
- if ((mib[3] = tcgetpgrp(fd)) == -1) {
662
- return NULL;
663
- }
664
-
665
- size = sizeof kp;
666
- if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1) {
667
- return NULL;
668
- }
669
-
670
- if (size != (sizeof kp) || *kp.kp_proc.p_comm == '\0') {
671
- return NULL;
672
- }
673
-
674
- return strdup(kp.kp_proc.p_comm);
675
- }
676
-
677
- #else
678
-
679
- static char *
680
- pty_getproc(int fd, char *tty) {
681
- return NULL;
682
- }
683
-
684
- #endif
685
-
686
- #if defined(__APPLE__)
687
- static void
688
- pty_posix_spawn(char** argv, char** env,
689
- const struct termios *termp,
690
- const struct winsize *winp,
691
- int* master,
692
- pid_t* pid,
693
- int* err) {
694
- int low_fds[3];
695
- size_t count = 0;
696
-
697
- for (; count < 3; count++) {
698
- low_fds[count] = posix_openpt(O_RDWR);
699
- if (low_fds[count] >= STDERR_FILENO)
700
- break;
701
- }
702
-
703
- int flags = POSIX_SPAWN_CLOEXEC_DEFAULT |
704
- POSIX_SPAWN_SETSIGDEF |
705
- POSIX_SPAWN_SETSIGMASK |
706
- POSIX_SPAWN_SETSID;
707
- *master = posix_openpt(O_RDWR);
708
- if (*master == -1) {
709
- return;
710
- }
711
-
712
- int res = grantpt(*master) || unlockpt(*master);
713
- if (res == -1) {
714
- return;
715
- }
716
-
717
- // Use TIOCPTYGNAME instead of ptsname() to avoid threading problems.
718
- int slave;
719
- char slave_pty_name[128];
720
- res = ioctl(*master, TIOCPTYGNAME, slave_pty_name);
721
- if (res == -1) {
722
- return;
723
- }
724
-
725
- slave = open(slave_pty_name, O_RDWR | O_NOCTTY);
726
- if (slave == -1) {
727
- return;
728
- }
729
-
730
- if (termp) {
731
- res = tcsetattr(slave, TCSANOW, termp);
732
- if (res == -1) {
733
- return;
734
- };
735
- }
736
-
737
- if (winp) {
738
- res = ioctl(slave, TIOCSWINSZ, winp);
739
- if (res == -1) {
740
- return;
741
- }
742
- }
743
-
744
- posix_spawn_file_actions_t acts;
745
- posix_spawn_file_actions_init(&acts);
746
- posix_spawn_file_actions_adddup2(&acts, slave, STDIN_FILENO);
747
- posix_spawn_file_actions_adddup2(&acts, slave, STDOUT_FILENO);
748
- posix_spawn_file_actions_adddup2(&acts, slave, STDERR_FILENO);
749
- posix_spawn_file_actions_addclose(&acts, slave);
750
- posix_spawn_file_actions_addclose(&acts, *master);
751
-
752
- posix_spawnattr_t attrs;
753
- posix_spawnattr_init(&attrs);
754
- *err = posix_spawnattr_setflags(&attrs, flags);
755
- if (*err != 0) {
756
- goto done;
757
- }
758
-
759
- sigset_t signal_set;
760
- /* Reset all signal the child to their default behavior */
761
- sigfillset(&signal_set);
762
- *err = posix_spawnattr_setsigdefault(&attrs, &signal_set);
763
- if (*err != 0) {
764
- goto done;
765
- }
766
-
767
- /* Reset the signal mask for all signals */
768
- sigemptyset(&signal_set);
769
- *err = posix_spawnattr_setsigmask(&attrs, &signal_set);
770
- if (*err != 0) {
771
- goto done;
772
- }
773
-
774
- do
775
- *err = posix_spawn(pid, argv[0], &acts, &attrs, argv, env);
776
- while (*err == EINTR);
777
- done:
778
- posix_spawn_file_actions_destroy(&acts);
779
- posix_spawnattr_destroy(&attrs);
780
-
781
- for (; count > 0; count--) {
782
- close(low_fds[count]);
783
- }
784
- }
785
- #endif
786
-
787
- /**
788
- * Init
789
- */
790
-
791
- Napi::Object init(Napi::Env env, Napi::Object exports) {
792
- exports.Set("fork", Napi::Function::New(env, PtyFork));
793
- exports.Set("open", Napi::Function::New(env, PtyOpen));
794
- exports.Set("resize", Napi::Function::New(env, PtyResize));
795
- exports.Set("process", Napi::Function::New(env, PtyGetProc));
796
- return exports;
797
- }
798
-
799
- NODE_API_MODULE(NODE_GYP_MODULE_NAME, init)