@jsonstudio/zterm-daemon-darwin-arm64 0.0.0-stage → 0.1.3
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/LICENSE +191 -0
- package/README.md +2 -2
- package/package.json +25 -4
- package/runtime/dagpipe.node +0 -0
- package/runtime/node_modules/@roamhq/wrtc/AUTHORS +17 -0
- package/runtime/node_modules/@roamhq/wrtc/CHANGELOG.md +1094 -0
- package/runtime/node_modules/@roamhq/wrtc/LICENSE.md +30 -0
- package/runtime/node_modules/@roamhq/wrtc/README.md +74 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/binding.js +31 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/browser.js +18 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/datachannelevent.js +26 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/datachannelmessageevent.js +9 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/error.js +20 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/eventtarget.js +59 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/icecandidate.js +43 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/index.js +85 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/mediadevices.js +30 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/peerconnection.js +333 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/rtcpeerconnectioniceerrorevent.js +36 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/rtcpeerconnectioniceevent.js +20 -0
- package/runtime/node_modules/@roamhq/wrtc/lib/sessiondescription.js +19 -0
- package/runtime/node_modules/@roamhq/wrtc/package.json +68 -0
- package/runtime/node_modules/@roamhq/wrtc/types/index.d.ts +32 -0
- package/runtime/node_modules/@roamhq/wrtc/types/nonstandard.d.ts +81 -0
- package/runtime/node_modules/@roamhq/wrtc-darwin-arm64/index.js +1 -0
- package/runtime/node_modules/@roamhq/wrtc-darwin-arm64/package.json +16 -0
- package/runtime/node_modules/@roamhq/wrtc-darwin-arm64/wrtc.node +0 -0
- package/runtime/node_modules/node-pty/LICENSE +69 -0
- package/runtime/node_modules/node-pty/README.md +165 -0
- package/runtime/node_modules/node-pty/binding.gyp +111 -0
- package/runtime/node_modules/node-pty/deps/.editorconfig +2 -0
- package/runtime/node_modules/node-pty/deps/winpty/.drone.yml +17 -0
- package/runtime/node_modules/node-pty/deps/winpty/.gitattributes +19 -0
- package/runtime/node_modules/node-pty/deps/winpty/LICENSE +21 -0
- package/runtime/node_modules/node-pty/deps/winpty/Makefile +166 -0
- package/runtime/node_modules/node-pty/deps/winpty/README.md +151 -0
- package/runtime/node_modules/node-pty/deps/winpty/RELEASES.md +280 -0
- package/runtime/node_modules/node-pty/deps/winpty/VERSION.txt +1 -0
- package/runtime/node_modules/node-pty/deps/winpty/configure +167 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/BufferResizeTests.cc +90 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ClearConsole.cc +72 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ConinMode.cc +117 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ConinMode.ps1 +116 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ConoutMode.cc +113 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/DebugClient.py +42 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/DebugServer.py +63 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/DumpLines.py +5 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/FontSurvey.cc +100 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/FormatChar.h +21 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/FreezePerfTest.cc +62 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/GetCh.cc +20 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/GetConsolePos.cc +41 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/GetFont.cc +261 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/IsNewConsole.cc +87 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/MouseInputNotes.txt +90 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Notes.txt +219 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/OSVersion.cc +27 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest.cc +671 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/SelectAllTest.cc +45 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/SetBufferSize.cc +32 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/SetCursorPos.cc +10 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/SetFont.cc +145 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/SetWindowRect.cc +36 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ShowArgv.cc +12 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/ShowConsoleInput.cc +40 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Spew.py +5 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/TestUtil.cc +172 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/UnixEcho.cc +89 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Utf16Echo.cc +46 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/VeryLargeRead.cc +122 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/VkEscapeTest.cc +56 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win10WrapTest1.cc +57 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win10WrapTest2.cc +30 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Echo1.cc +26 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Echo2.cc +19 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Test1.cc +46 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Test2.cc +70 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Test3.cc +78 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/Win32Write1.cc +44 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/WriteConsole.cc +106 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/build32.sh +9 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/build64.sh +9 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/color-test.sh +212 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/font-notes.txt +300 -0
- package/runtime/node_modules/node-pty/deps/winpty/misc/winbug-15048.cc +201 -0
- package/runtime/node_modules/node-pty/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
- package/runtime/node_modules/node-pty/deps/winpty/ship/common_ship.py +53 -0
- package/runtime/node_modules/node-pty/deps/winpty/ship/make_msvc_package.py +165 -0
- package/runtime/node_modules/node-pty/deps/winpty/ship/ship.py +108 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Agent.cc +613 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Agent.h +103 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.cc +632 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleFont.h +28 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.cc +852 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleInput.h +109 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.cc +152 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/ConsoleLine.h +41 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Coord.h +87 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.cc +239 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/DebugShowInput.h +32 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/DefaultInputMap.h +28 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/DsrSender.h +30 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/EventLoop.cc +99 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/EventLoop.h +47 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/InputMap.cc +246 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/InputMap.h +114 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.cc +378 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/NamedPipe.h +125 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Scraper.cc +699 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Scraper.h +103 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/SimplePool.h +75 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/SmallRect.h +143 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Terminal.cc +535 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Terminal.h +69 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Win32Console.cc +107 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Win32Console.h +67 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/main.cc +114 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/agent/subdir.mk +61 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/configurations.gypi +60 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/debugserver/DebugServer.cc +117 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/debugserver/subdir.mk +41 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/include/winpty.h +242 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/include/winpty_constants.h +131 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/subdir.mk +46 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/libwinpty/winpty.cc +970 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/AgentMsg.h +38 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/Buffer.cc +103 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/Buffer.h +102 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/DebugClient.cc +187 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/DebugClient.h +38 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/GenRandom.cc +138 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/GenRandom.h +55 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/GetCommitHash.bat +13 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/Mutex.h +54 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/OsModule.h +63 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.cc +36 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/OwnedHandle.h +45 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/StringBuilder.h +227 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/StringUtil.cc +55 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/StringUtil.h +80 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/TimeMeasurement.h +63 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WindowsSecurity.h +104 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.cc +252 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WindowsVersion.h +29 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.cc +55 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyAssert.h +64 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyException.cc +57 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyException.h +43 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.cc +42 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/WinptyVersion.h +27 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/shared/winpty_snprintf.h +99 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/subdir.mk +5 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/tests/subdir.mk +28 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/tests/trivial_test.cc +158 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.cc +86 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/Util.h +31 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/main.cc +729 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/unix-adapter/subdir.mk +41 -0
- package/runtime/node_modules/node-pty/deps/winpty/src/winpty.gyp +234 -0
- package/runtime/node_modules/node-pty/deps/winpty/vcbuild.bat +83 -0
- package/runtime/node_modules/node-pty/lib/conpty_console_list_agent.js +16 -0
- package/runtime/node_modules/node-pty/lib/conpty_console_list_agent.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/eventEmitter2.js +47 -0
- package/runtime/node_modules/node-pty/lib/eventEmitter2.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/eventEmitter2.test.js +30 -0
- package/runtime/node_modules/node-pty/lib/eventEmitter2.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/index.js +52 -0
- package/runtime/node_modules/node-pty/lib/index.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/interfaces.js +7 -0
- package/runtime/node_modules/node-pty/lib/interfaces.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/shared/conout.js +11 -0
- package/runtime/node_modules/node-pty/lib/shared/conout.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/terminal.js +190 -0
- package/runtime/node_modules/node-pty/lib/terminal.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/terminal.test.js +139 -0
- package/runtime/node_modules/node-pty/lib/terminal.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/testUtils.test.js +28 -0
- package/runtime/node_modules/node-pty/lib/testUtils.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/types.js +7 -0
- package/runtime/node_modules/node-pty/lib/types.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/unixTerminal.js +346 -0
- package/runtime/node_modules/node-pty/lib/unixTerminal.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/unixTerminal.test.js +351 -0
- package/runtime/node_modules/node-pty/lib/unixTerminal.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/utils.js +39 -0
- package/runtime/node_modules/node-pty/lib/utils.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/windowsConoutConnection.js +125 -0
- package/runtime/node_modules/node-pty/lib/windowsConoutConnection.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/windowsPtyAgent.js +320 -0
- package/runtime/node_modules/node-pty/lib/windowsPtyAgent.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/windowsPtyAgent.test.js +90 -0
- package/runtime/node_modules/node-pty/lib/windowsPtyAgent.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/windowsTerminal.js +199 -0
- package/runtime/node_modules/node-pty/lib/windowsTerminal.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/windowsTerminal.test.js +219 -0
- package/runtime/node_modules/node-pty/lib/windowsTerminal.test.js.map +1 -0
- package/runtime/node_modules/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/runtime/node_modules/node-pty/lib/worker/conoutSocketWorker.js.map +1 -0
- package/runtime/node_modules/node-pty/package.json +64 -0
- package/runtime/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/runtime/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/pty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/pty.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-arm64/winpty.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/pty.node +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/pty.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/winpty-agent.pdb +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
- package/runtime/node_modules/node-pty/prebuilds/win32-x64/winpty.pdb +0 -0
- package/runtime/node_modules/node-pty/scripts/gen-compile-commands.js +8 -0
- package/runtime/node_modules/node-pty/scripts/increment-version.js +54 -0
- package/runtime/node_modules/node-pty/scripts/post-install.js +80 -0
- package/runtime/node_modules/node-pty/scripts/prebuild.js +34 -0
- package/runtime/node_modules/node-pty/src/conpty_console_list_agent.ts +15 -0
- package/runtime/node_modules/node-pty/src/eventEmitter2.test.ts +30 -0
- package/runtime/node_modules/node-pty/src/eventEmitter2.ts +48 -0
- package/runtime/node_modules/node-pty/src/index.ts +52 -0
- package/runtime/node_modules/node-pty/src/interfaces.ts +130 -0
- package/runtime/node_modules/node-pty/src/native.d.ts +54 -0
- package/runtime/node_modules/node-pty/src/shared/conout.ts +15 -0
- package/runtime/node_modules/node-pty/src/terminal.test.ts +119 -0
- package/runtime/node_modules/node-pty/src/terminal.ts +211 -0
- package/runtime/node_modules/node-pty/src/testUtils.test.ts +23 -0
- package/runtime/node_modules/node-pty/src/tsconfig.json +22 -0
- package/runtime/node_modules/node-pty/src/types.ts +15 -0
- package/runtime/node_modules/node-pty/src/unix/pty.cc +799 -0
- package/runtime/node_modules/node-pty/src/unix/spawn-helper.cc +23 -0
- package/runtime/node_modules/node-pty/src/unixTerminal.test.ts +367 -0
- package/runtime/node_modules/node-pty/src/unixTerminal.ts +388 -0
- package/runtime/node_modules/node-pty/src/utils.ts +29 -0
- package/runtime/node_modules/node-pty/src/win/conpty.cc +583 -0
- package/runtime/node_modules/node-pty/src/win/conpty.h +41 -0
- package/runtime/node_modules/node-pty/src/win/conpty_console_list.cc +44 -0
- package/runtime/node_modules/node-pty/src/win/path_util.cc +95 -0
- package/runtime/node_modules/node-pty/src/win/path_util.h +26 -0
- package/runtime/node_modules/node-pty/src/win/winpty.cc +333 -0
- package/runtime/node_modules/node-pty/src/windowsConoutConnection.ts +82 -0
- package/runtime/node_modules/node-pty/src/windowsPtyAgent.test.ts +94 -0
- package/runtime/node_modules/node-pty/src/windowsPtyAgent.ts +321 -0
- package/runtime/node_modules/node-pty/src/windowsTerminal.test.ts +229 -0
- package/runtime/node_modules/node-pty/src/windowsTerminal.ts +203 -0
- package/runtime/node_modules/node-pty/src/worker/conoutSocketWorker.ts +22 -0
- package/runtime/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
- package/runtime/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
- package/runtime/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
- package/runtime/node_modules/node-pty/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
- package/runtime/node_modules/node-pty/typings/node-pty.d.ts +211 -0
- package/runtime/server.cjs +27142 -0
- package/support/terminal-config-command.cjs +579 -0
- package/support/zterm-daemon +0 -0
- package/support/zterm-daemon.sh +742 -0
- package/zterm-package.json +27 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
PACKAGE_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
5
|
+
PACKAGE_ROOT="$(python3 - "$PACKAGE_ROOT" <<'PY'
|
|
6
|
+
import os, sys
|
|
7
|
+
print(os.path.realpath(sys.argv[1]))
|
|
8
|
+
PY
|
|
9
|
+
)"
|
|
10
|
+
NODE_BIN="$(command -v node)"
|
|
11
|
+
LOG_DIR="${HOME}/.zterm/logs"
|
|
12
|
+
WTERM_HOME="${HOME}/.zterm"
|
|
13
|
+
WTERM_BIN_DIR="${WTERM_HOME}/bin"
|
|
14
|
+
RUNTIME_STATE_DIR="${WTERM_HOME}/run"
|
|
15
|
+
UPLOAD_DIR="${WTERM_HOME}/uploads"
|
|
16
|
+
DOWNLOADS_DIR="${HOME}/Downloads/zterm"
|
|
17
|
+
RUNTIME_DIR="${PACKAGE_ROOT}/runtime"
|
|
18
|
+
DAEMON_PID_FILE="${RUNTIME_STATE_DIR}/zterm-daemon.pid"
|
|
19
|
+
DIRECT_RUNNER="${WTERM_BIN_DIR}/zterm-daemon-run"
|
|
20
|
+
LAUNCH_RUNNER="${WTERM_BIN_DIR}/zterm-daemon-launchd-run"
|
|
21
|
+
LAUNCH_AGENT_LABEL="com.zterm.android.zterm-daemon"
|
|
22
|
+
LAUNCH_AGENT_PATH="${HOME}/Library/LaunchAgents/${LAUNCH_AGENT_LABEL}.plist"
|
|
23
|
+
PREVIOUS_LAUNCH_AGENT_LABEL="com.zterm.android.daemon"
|
|
24
|
+
PREVIOUS_LAUNCH_AGENT_PATH="${HOME}/Library/LaunchAgents/${PREVIOUS_LAUNCH_AGENT_LABEL}.plist"
|
|
25
|
+
LEGACY_LAUNCH_AGENT_LABEL="com.zterm.mobile.daemon"
|
|
26
|
+
LEGACY_LAUNCH_AGENT_PATH="${HOME}/Library/LaunchAgents/${LEGACY_LAUNCH_AGENT_LABEL}.plist"
|
|
27
|
+
STAGED_DAEMON_ENTRY="${RUNTIME_DIR}/server.cjs"
|
|
28
|
+
TERMINAL_CONFIG_COMMAND="${PACKAGE_ROOT}/support/terminal-config-command.cjs"
|
|
29
|
+
STAGED_NODE_PTY_HELPER_GLOB="${RUNTIME_DIR}/node_modules/node-pty/prebuilds/darwin-*/spawn-helper"
|
|
30
|
+
NATIVE_DAEMON_BIN="${WTERM_BIN_DIR}/zterm-daemon"
|
|
31
|
+
DAGPIPE_NATIVE_BIN="${RUNTIME_DIR}/dagpipe.node"
|
|
32
|
+
ITERM2_PYTHON_VENV="${WTERM_HOME}/python/iterm2"
|
|
33
|
+
ITERM2_PYTHON_BIN="${ITERM2_PYTHON_VENV}/bin/python3"
|
|
34
|
+
|
|
35
|
+
read_config() {
|
|
36
|
+
"$NODE_BIN" "$TERMINAL_CONFIG_COMMAND" daemon-config --shell
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
config_output="$(read_config)"
|
|
40
|
+
eval "$config_output"
|
|
41
|
+
|
|
42
|
+
PROBE_SOCKET_HOST="$HOST"
|
|
43
|
+
PROBE_URL_HOST="$HOST"
|
|
44
|
+
case "$PROBE_SOCKET_HOST" in
|
|
45
|
+
0.0.0.0|::|\[::\])
|
|
46
|
+
PROBE_SOCKET_HOST="127.0.0.1"
|
|
47
|
+
PROBE_URL_HOST="127.0.0.1"
|
|
48
|
+
;;
|
|
49
|
+
\[*\])
|
|
50
|
+
PROBE_SOCKET_HOST="${PROBE_SOCKET_HOST#[}"
|
|
51
|
+
PROBE_SOCKET_HOST="${PROBE_SOCKET_HOST%]}"
|
|
52
|
+
PROBE_URL_HOST="[${PROBE_SOCKET_HOST}]"
|
|
53
|
+
;;
|
|
54
|
+
*:*)
|
|
55
|
+
PROBE_URL_HOST="[${PROBE_SOCKET_HOST}]"
|
|
56
|
+
;;
|
|
57
|
+
esac
|
|
58
|
+
|
|
59
|
+
usage() {
|
|
60
|
+
cat <<'USAGE'
|
|
61
|
+
Usage:
|
|
62
|
+
zterm-daemon run
|
|
63
|
+
zterm-daemon start
|
|
64
|
+
zterm-daemon status
|
|
65
|
+
zterm-daemon config
|
|
66
|
+
zterm-daemon stop
|
|
67
|
+
zterm-daemon restart
|
|
68
|
+
zterm-daemon configure-relay --relay-url URL --username USER --password-stdin --host-id HOST_ID [--device-name NAME] [--restart-service]
|
|
69
|
+
zterm-daemon install-service
|
|
70
|
+
zterm-daemon uninstall-service
|
|
71
|
+
zterm-daemon service-status
|
|
72
|
+
USAGE
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
configure_relay() {
|
|
76
|
+
local relay_url=""
|
|
77
|
+
local relay_username=""
|
|
78
|
+
local relay_password=""
|
|
79
|
+
local relay_host_id=""
|
|
80
|
+
local relay_device_id=""
|
|
81
|
+
local relay_device_name=""
|
|
82
|
+
local password_stdin="0"
|
|
83
|
+
local restart_after_config="0"
|
|
84
|
+
|
|
85
|
+
if [[ "${1:-}" == "configure-relay" ]]; then
|
|
86
|
+
shift
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
while [[ $# -gt 0 ]]; do
|
|
90
|
+
case "$1" in
|
|
91
|
+
--relay-url)
|
|
92
|
+
relay_url="${2:-}"
|
|
93
|
+
shift 2
|
|
94
|
+
;;
|
|
95
|
+
--username)
|
|
96
|
+
relay_username="${2:-}"
|
|
97
|
+
shift 2
|
|
98
|
+
;;
|
|
99
|
+
--password)
|
|
100
|
+
echo "relay passwords are accepted only with --password-stdin" >&2
|
|
101
|
+
return 1
|
|
102
|
+
;;
|
|
103
|
+
--password-stdin)
|
|
104
|
+
IFS= read -r relay_password
|
|
105
|
+
password_stdin="1"
|
|
106
|
+
shift
|
|
107
|
+
;;
|
|
108
|
+
--password-env)
|
|
109
|
+
echo "relay passwords are accepted only with --password-stdin" >&2
|
|
110
|
+
return 1
|
|
111
|
+
;;
|
|
112
|
+
--host-id)
|
|
113
|
+
relay_host_id="${2:-}"
|
|
114
|
+
shift 2
|
|
115
|
+
;;
|
|
116
|
+
--device-id)
|
|
117
|
+
relay_device_id="${2:-}"
|
|
118
|
+
shift 2
|
|
119
|
+
;;
|
|
120
|
+
--device-name)
|
|
121
|
+
relay_device_name="${2:-}"
|
|
122
|
+
shift 2
|
|
123
|
+
;;
|
|
124
|
+
--restart-service)
|
|
125
|
+
restart_after_config="1"
|
|
126
|
+
shift
|
|
127
|
+
;;
|
|
128
|
+
--no-restart)
|
|
129
|
+
restart_after_config="0"
|
|
130
|
+
shift
|
|
131
|
+
;;
|
|
132
|
+
-h|--help)
|
|
133
|
+
usage
|
|
134
|
+
return 0
|
|
135
|
+
;;
|
|
136
|
+
*)
|
|
137
|
+
echo "unknown configure-relay option: $1" >&2
|
|
138
|
+
return 1
|
|
139
|
+
;;
|
|
140
|
+
esac
|
|
141
|
+
done
|
|
142
|
+
|
|
143
|
+
if [[ -z "$relay_url" || -z "$relay_username" || -z "$relay_password" || -z "$relay_host_id" || "$password_stdin" != "1" ]]; then
|
|
144
|
+
echo "configure-relay requires --relay-url, --username, --password-stdin, and --host-id" >&2
|
|
145
|
+
return 1
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
local -a configure_args=(
|
|
149
|
+
"$TERMINAL_CONFIG_COMMAND"
|
|
150
|
+
configure-relay
|
|
151
|
+
--relay-url "$relay_url"
|
|
152
|
+
--username "$relay_username"
|
|
153
|
+
--host-id "$relay_host_id"
|
|
154
|
+
--password-stdin
|
|
155
|
+
)
|
|
156
|
+
if [[ -n "$relay_device_id" ]]; then
|
|
157
|
+
configure_args+=(--device-id "$relay_device_id")
|
|
158
|
+
fi
|
|
159
|
+
if [[ -n "$relay_device_name" ]]; then
|
|
160
|
+
configure_args+=(--device-name "$relay_device_name")
|
|
161
|
+
fi
|
|
162
|
+
printf '%s\n' "$relay_password" | "$NODE_BIN" "${configure_args[@]}"
|
|
163
|
+
if [[ "$restart_after_config" == "1" ]]; then
|
|
164
|
+
restart_service
|
|
165
|
+
else
|
|
166
|
+
echo "run 'zterm-daemon restart' after configuration to reconnect relay"
|
|
167
|
+
fi
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
service_installed() {
|
|
171
|
+
[[ -f "$LAUNCH_AGENT_PATH" ]]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
service_loaded() {
|
|
175
|
+
launchctl print "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" >/dev/null 2>&1
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
legacy_service_loaded() {
|
|
179
|
+
launchctl print "gui/$(id -u)/${LEGACY_LAUNCH_AGENT_LABEL}" >/dev/null 2>&1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
previous_service_loaded() {
|
|
183
|
+
launchctl print "gui/$(id -u)/${PREVIOUS_LAUNCH_AGENT_LABEL}" >/dev/null 2>&1
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
service_snapshot() {
|
|
187
|
+
launchctl print "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" 2>/dev/null || true
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
wait_for_service_ready() {
|
|
191
|
+
local attempts=0
|
|
192
|
+
local max_attempts=150
|
|
193
|
+
while (( attempts < max_attempts )); do
|
|
194
|
+
if daemon_health_ready; then
|
|
195
|
+
return 0
|
|
196
|
+
fi
|
|
197
|
+
sleep 0.2
|
|
198
|
+
attempts=$((attempts + 1))
|
|
199
|
+
done
|
|
200
|
+
return 1
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
wait_for_service_unloaded() {
|
|
204
|
+
local attempts=0
|
|
205
|
+
local max_attempts=30
|
|
206
|
+
|
|
207
|
+
while (( attempts < max_attempts )); do
|
|
208
|
+
if ! service_loaded; then
|
|
209
|
+
return 0
|
|
210
|
+
fi
|
|
211
|
+
sleep 0.2
|
|
212
|
+
attempts=$((attempts + 1))
|
|
213
|
+
done
|
|
214
|
+
|
|
215
|
+
return 1
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
port_listening() {
|
|
219
|
+
nc -z "${PROBE_SOCKET_HOST}" "${PORT}" >/dev/null 2>&1
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
daemon_health_ready() {
|
|
223
|
+
curl --silent --show-error --fail --max-time 2 "http://${PROBE_URL_HOST}:${PORT}/health" >/dev/null 2>&1
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
wait_for_port_closed() {
|
|
227
|
+
local attempts=0
|
|
228
|
+
local max_attempts=30
|
|
229
|
+
while (( attempts < max_attempts )); do
|
|
230
|
+
if ! port_listening; then
|
|
231
|
+
return 0
|
|
232
|
+
fi
|
|
233
|
+
sleep 0.2
|
|
234
|
+
attempts=$((attempts + 1))
|
|
235
|
+
done
|
|
236
|
+
return 1
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
reset_launch_crash_guard() {
|
|
240
|
+
rm -f "${RUNTIME_STATE_DIR}/zterm-daemon-launch-crashes.log"
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
read_daemon_pid() {
|
|
244
|
+
[[ -f "${DAEMON_PID_FILE}" ]] || return 1
|
|
245
|
+
local pid
|
|
246
|
+
pid="$(tr -d '[:space:]' < "${DAEMON_PID_FILE}")"
|
|
247
|
+
[[ -n "${pid}" ]] || return 1
|
|
248
|
+
printf '%s\n' "${pid}"
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
is_process_running() {
|
|
252
|
+
local pid="${1:-}"
|
|
253
|
+
[[ -n "${pid}" ]] || return 1
|
|
254
|
+
kill -0 "${pid}" >/dev/null 2>&1
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
run_foreground() {
|
|
258
|
+
mkdir -p "$LOG_DIR"
|
|
259
|
+
chmod +x ${STAGED_NODE_PTY_HELPER_GLOB} 2>/dev/null || true
|
|
260
|
+
cd "${HOME}"
|
|
261
|
+
exec env -u TMUX -u TMUX_PANE HOST="$HOST" PORT="$PORT" ZTERM_HOST="$HOST" ZTERM_PORT="$PORT" ZTERM_AUTH_TOKEN="${ZTERM_AUTH_TOKEN:-}" ZTERM_DAEMON_NATIVE="$NATIVE_DAEMON_BIN" ZTERM_DAGPIPE_NATIVE="${DAGPIPE_NATIVE_BIN}" "$NODE_BIN" "$STAGED_DAEMON_ENTRY"
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
status_direct() {
|
|
265
|
+
local pid=""
|
|
266
|
+
if pid="$(read_daemon_pid 2>/dev/null)" && is_process_running "${pid}" && port_listening; then
|
|
267
|
+
echo "zterm daemon running: pid=${pid} host=${HOST} port=${PORT} auth=${AUTH_SOURCE}"
|
|
268
|
+
return 0
|
|
269
|
+
fi
|
|
270
|
+
if [[ -n "${pid}" ]] && ! is_process_running "${pid}"; then
|
|
271
|
+
rm -f "${DAEMON_PID_FILE}"
|
|
272
|
+
fi
|
|
273
|
+
if port_listening; then
|
|
274
|
+
echo "zterm daemon listener is up on port ${PORT}, but managed pid truth is missing"
|
|
275
|
+
echo "pidFile=${DAEMON_PID_FILE} host=${HOST} auth=${AUTH_SOURCE}"
|
|
276
|
+
return 1
|
|
277
|
+
fi
|
|
278
|
+
echo "zterm daemon not running (${PORT})"
|
|
279
|
+
echo "config=${CONFIG_DISPLAY_PATH} found=${CONFIG_FOUND} auth=${AUTH_SOURCE}"
|
|
280
|
+
return 1
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
status_service() {
|
|
284
|
+
if ! service_installed; then
|
|
285
|
+
echo "zterm autostart service not installed"
|
|
286
|
+
echo "plist=${LAUNCH_AGENT_PATH}"
|
|
287
|
+
return 1
|
|
288
|
+
fi
|
|
289
|
+
local snapshot last_exit active_count
|
|
290
|
+
snapshot="$(service_snapshot)"
|
|
291
|
+
last_exit="$(printf '%s\n' "$snapshot" | awk '/last exit code =/ { print $5; exit }')"
|
|
292
|
+
active_count="$(printf '%s\n' "$snapshot" | awk '/active count =/ { print $4; exit }')"
|
|
293
|
+
if [[ "${active_count:-0}" != "0" ]] && daemon_health_ready; then
|
|
294
|
+
echo "zterm autostart service running: label=${LAUNCH_AGENT_LABEL} host=${HOST} port=${PORT} auth=${AUTH_SOURCE}"
|
|
295
|
+
echo "plist=${LAUNCH_AGENT_PATH}"
|
|
296
|
+
echo "active_count=${active_count:-unknown} last_exit=${last_exit:-unknown}"
|
|
297
|
+
return 0
|
|
298
|
+
fi
|
|
299
|
+
echo "zterm autostart service installed but unhealthy: label=${LAUNCH_AGENT_LABEL}"
|
|
300
|
+
echo "plist=${LAUNCH_AGENT_PATH}"
|
|
301
|
+
echo "active_count=${active_count:-unknown} last_exit=${last_exit:-unknown}"
|
|
302
|
+
echo "health=down url=http://${PROBE_URL_HOST}:${PORT}/health"
|
|
303
|
+
return 1
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
status() {
|
|
307
|
+
if service_installed; then
|
|
308
|
+
if status_service; then
|
|
309
|
+
return 0
|
|
310
|
+
fi
|
|
311
|
+
status_direct
|
|
312
|
+
return $?
|
|
313
|
+
fi
|
|
314
|
+
status_direct
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
start_direct() {
|
|
318
|
+
mkdir -p "$LOG_DIR" "$RUNTIME_STATE_DIR"
|
|
319
|
+
local timestamp log_file
|
|
320
|
+
timestamp="$(date +%Y%m%d-%H%M%S)"
|
|
321
|
+
log_file="${LOG_DIR}/daemon-${PORT}-${timestamp}.log"
|
|
322
|
+
local existing_pid=""
|
|
323
|
+
if existing_pid="$(read_daemon_pid 2>/dev/null)" && is_process_running "${existing_pid}" && port_listening; then
|
|
324
|
+
echo "zterm daemon already running: pid=${existing_pid} host=${HOST} port=${PORT} auth=${AUTH_SOURCE}"
|
|
325
|
+
echo "pidFile=${DAEMON_PID_FILE}"
|
|
326
|
+
return 0
|
|
327
|
+
fi
|
|
328
|
+
if [[ -n "${existing_pid}" ]] && ! is_process_running "${existing_pid}"; then
|
|
329
|
+
rm -f "${DAEMON_PID_FILE}"
|
|
330
|
+
fi
|
|
331
|
+
if port_listening; then
|
|
332
|
+
echo "zterm daemon listener already exists on port ${PORT}, but managed pid truth is missing"
|
|
333
|
+
echo "pidFile=${DAEMON_PID_FILE}"
|
|
334
|
+
return 1
|
|
335
|
+
fi
|
|
336
|
+
chmod +x ${STAGED_NODE_PTY_HELPER_GLOB} 2>/dev/null || true
|
|
337
|
+
(
|
|
338
|
+
cd "${HOME}"
|
|
339
|
+
env -u TMUX -u TMUX_PANE HOST="$HOST" PORT="$PORT" ZTERM_HOST="$HOST" ZTERM_PORT="$PORT" ZTERM_AUTH_TOKEN="${ZTERM_AUTH_TOKEN:-}" ZTERM_DAEMON_NATIVE="$NATIVE_DAEMON_BIN" \
|
|
340
|
+
"$NODE_BIN" "$STAGED_DAEMON_ENTRY" >>"$log_file" 2>&1
|
|
341
|
+
) &
|
|
342
|
+
local daemon_pid=$!
|
|
343
|
+
printf '%s\n' "${daemon_pid}" > "${DAEMON_PID_FILE}"
|
|
344
|
+
if ! wait_for_service_ready; then
|
|
345
|
+
if is_process_running "${daemon_pid}"; then
|
|
346
|
+
kill "${daemon_pid}" >/dev/null 2>&1 || true
|
|
347
|
+
wait "${daemon_pid}" 2>/dev/null || true
|
|
348
|
+
fi
|
|
349
|
+
rm -f "${DAEMON_PID_FILE}"
|
|
350
|
+
echo "zterm daemon failed to become ready on port ${PORT}"
|
|
351
|
+
echo "log=${log_file}"
|
|
352
|
+
return 1
|
|
353
|
+
fi
|
|
354
|
+
echo "zterm daemon started"
|
|
355
|
+
echo "pid=${daemon_pid}"
|
|
356
|
+
echo "host=${HOST}"
|
|
357
|
+
echo "port=${PORT}"
|
|
358
|
+
echo "auth=${AUTH_SOURCE}"
|
|
359
|
+
echo "config=${CONFIG_DISPLAY_PATH}"
|
|
360
|
+
echo "pidFile=${DAEMON_PID_FILE}"
|
|
361
|
+
echo "log=${log_file}"
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
stop_direct() {
|
|
365
|
+
local pid=""
|
|
366
|
+
if ! pid="$(read_daemon_pid 2>/dev/null)"; then
|
|
367
|
+
if port_listening; then
|
|
368
|
+
echo "zterm daemon listener is up on port ${PORT}, but managed pid truth is missing"
|
|
369
|
+
echo "pidFile=${DAEMON_PID_FILE}"
|
|
370
|
+
return 1
|
|
371
|
+
fi
|
|
372
|
+
echo "zterm daemon not running (${PORT})"
|
|
373
|
+
return 0
|
|
374
|
+
fi
|
|
375
|
+
if ! is_process_running "${pid}"; then
|
|
376
|
+
rm -f "${DAEMON_PID_FILE}"
|
|
377
|
+
if port_listening; then
|
|
378
|
+
echo "zterm daemon listener is up on port ${PORT}, but pid ${pid} is stale"
|
|
379
|
+
return 1
|
|
380
|
+
fi
|
|
381
|
+
echo "zterm daemon not running (${PORT})"
|
|
382
|
+
return 0
|
|
383
|
+
fi
|
|
384
|
+
kill "${pid}"
|
|
385
|
+
if ! wait_for_port_closed; then
|
|
386
|
+
echo "zterm daemon did not stop listening on port ${PORT} after pid ${pid} was terminated"
|
|
387
|
+
return 1
|
|
388
|
+
fi
|
|
389
|
+
wait "${pid}" 2>/dev/null || true
|
|
390
|
+
rm -f "${DAEMON_PID_FILE}"
|
|
391
|
+
echo "zterm daemon stopped: pid=${pid}"
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
prepare_iterm2_python_env() {
|
|
395
|
+
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
396
|
+
return 0
|
|
397
|
+
fi
|
|
398
|
+
mkdir -p "${WTERM_HOME}/python"
|
|
399
|
+
if [[ ! -x "$ITERM2_PYTHON_BIN" ]]; then
|
|
400
|
+
python3 -m venv "$ITERM2_PYTHON_VENV"
|
|
401
|
+
fi
|
|
402
|
+
if "$ITERM2_PYTHON_BIN" - <<'PY' >/dev/null 2>&1
|
|
403
|
+
import iterm2
|
|
404
|
+
PY
|
|
405
|
+
then
|
|
406
|
+
return 0
|
|
407
|
+
fi
|
|
408
|
+
"$ITERM2_PYTHON_BIN" -m pip install --upgrade pip >/dev/null
|
|
409
|
+
"$ITERM2_PYTHON_BIN" -m pip install --upgrade iterm2
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
write_launch_agent() {
|
|
413
|
+
prepare_iterm2_python_env || echo "[zterm-daemon] iTerm2 Python API environment unavailable; remote-window pane catalog will report an explicit error" >&2
|
|
414
|
+
mkdir -p "${HOME}/Library/LaunchAgents" "$LOG_DIR" "$WTERM_BIN_DIR" "$RUNTIME_STATE_DIR"
|
|
415
|
+
cat > "$DIRECT_RUNNER" <<RUNNER
|
|
416
|
+
#!/usr/bin/env bash
|
|
417
|
+
set -euo pipefail
|
|
418
|
+
cd "${HOME}"
|
|
419
|
+
export PATH="${HOME}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
|
|
420
|
+
chmod +x ${STAGED_NODE_PTY_HELPER_GLOB} 2>/dev/null || true
|
|
421
|
+
exec env -u TMUX -u TMUX_PANE ZTERM_ITERM2_PYTHON="${ITERM2_PYTHON_BIN}" ZTERM_DAEMON_NATIVE="${NATIVE_DAEMON_BIN}" ZTERM_DAGPIPE_NATIVE="${DAGPIPE_NATIVE_BIN}" "${NODE_BIN}" "${STAGED_DAEMON_ENTRY}"
|
|
422
|
+
RUNNER
|
|
423
|
+
chmod +x "$DIRECT_RUNNER"
|
|
424
|
+
|
|
425
|
+
cat > "$LAUNCH_RUNNER" <<RUNNER
|
|
426
|
+
#!/usr/bin/env bash
|
|
427
|
+
set -euo pipefail
|
|
428
|
+
PORT="${PORT}"
|
|
429
|
+
PROBE_URL_HOST="${PROBE_URL_HOST}"
|
|
430
|
+
STATE_DIR="${RUNTIME_STATE_DIR}"
|
|
431
|
+
CRASH_FILE="${RUNTIME_STATE_DIR}/zterm-daemon-launch-crashes.log"
|
|
432
|
+
mkdir -p "\$STATE_DIR"
|
|
433
|
+
health_ready() {
|
|
434
|
+
curl --silent --show-error --fail --max-time 2 "http://\${PROBE_URL_HOST}:\${PORT}/health" >/dev/null 2>&1
|
|
435
|
+
}
|
|
436
|
+
if health_ready; then
|
|
437
|
+
echo "[\$(date -u +%Y-%m-%dT%H:%M:%SZ)] launchd preflight: health ok on port \$PORT, skip duplicate start" >> "${LOG_DIR}/launchd-stdout.log"
|
|
438
|
+
exit 0
|
|
439
|
+
fi
|
|
440
|
+
RECENT_LAUNCHES="\$(
|
|
441
|
+
if [[ -f "\$CRASH_FILE" ]]; then
|
|
442
|
+
python3 - "\$CRASH_FILE" "\$(date +%s)" <<'PY'
|
|
443
|
+
import pathlib, sys
|
|
444
|
+
path = pathlib.Path(sys.argv[1])
|
|
445
|
+
now = int(sys.argv[2])
|
|
446
|
+
cutoff = now - 120
|
|
447
|
+
entries = []
|
|
448
|
+
for line in path.read_text().splitlines():
|
|
449
|
+
try:
|
|
450
|
+
value = int(line.strip())
|
|
451
|
+
except ValueError:
|
|
452
|
+
continue
|
|
453
|
+
if value >= cutoff:
|
|
454
|
+
entries.append(value)
|
|
455
|
+
entries.append(now)
|
|
456
|
+
path.write_text("\n".join(str(item) for item in entries[-8:]) + "\n")
|
|
457
|
+
print(len(entries))
|
|
458
|
+
PY
|
|
459
|
+
else
|
|
460
|
+
printf '%s\n' "\$(date +%s)" > "\$CRASH_FILE"
|
|
461
|
+
echo 1
|
|
462
|
+
fi
|
|
463
|
+
)"
|
|
464
|
+
if [[ "\${RECENT_LAUNCHES:-0}" -ge 5 ]]; then
|
|
465
|
+
echo "[\$(date -u +%Y-%m-%dT%H:%M:%SZ)] launchd preflight: crash-loop guard tripped (\${RECENT_LAUNCHES} launches/120s), stop auto-restart" >> "${LOG_DIR}/launchd-stderr.log"
|
|
466
|
+
exit 0
|
|
467
|
+
fi
|
|
468
|
+
cd "${HOME}"
|
|
469
|
+
export PATH="${HOME}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
|
|
470
|
+
chmod +x ${STAGED_NODE_PTY_HELPER_GLOB} 2>/dev/null || true
|
|
471
|
+
child_pid=""
|
|
472
|
+
terminate_child() {
|
|
473
|
+
[[ -n "\${child_pid}" ]] || return 0
|
|
474
|
+
kill -0 "\${child_pid}" >/dev/null 2>&1 || return 0
|
|
475
|
+
kill -TERM "\${child_pid}" >/dev/null 2>&1 || true
|
|
476
|
+
for _ in 1 2 3 4 5; do
|
|
477
|
+
kill -0 "\${child_pid}" >/dev/null 2>&1 || break
|
|
478
|
+
sleep 1
|
|
479
|
+
done
|
|
480
|
+
if kill -0 "\${child_pid}" >/dev/null 2>&1; then
|
|
481
|
+
kill -KILL "\${child_pid}" >/dev/null 2>&1 || true
|
|
482
|
+
fi
|
|
483
|
+
wait "\${child_pid}" >/dev/null 2>&1 || true
|
|
484
|
+
}
|
|
485
|
+
cleanup_child() {
|
|
486
|
+
terminate_child
|
|
487
|
+
}
|
|
488
|
+
trap cleanup_child TERM INT
|
|
489
|
+
env -u TMUX -u TMUX_PANE ZTERM_ITERM2_PYTHON="${ITERM2_PYTHON_BIN}" ZTERM_DAEMON_NATIVE="${NATIVE_DAEMON_BIN}" ZTERM_DAGPIPE_NATIVE="${DAGPIPE_NATIVE_BIN}" "${NODE_BIN}" "${STAGED_DAEMON_ENTRY}" &
|
|
490
|
+
child_pid="\$!"
|
|
491
|
+
missed_health_checks=0
|
|
492
|
+
child_start_epoch="\$(date +%s)"
|
|
493
|
+
STARTUP_HEALTH_GRACE_SECONDS=45
|
|
494
|
+
while kill -0 "\${child_pid}" >/dev/null 2>&1; do
|
|
495
|
+
if health_ready; then
|
|
496
|
+
missed_health_checks=0
|
|
497
|
+
else
|
|
498
|
+
now_epoch="\$(date +%s)"
|
|
499
|
+
child_age=\$((now_epoch - child_start_epoch))
|
|
500
|
+
if [[ "\${child_age}" -lt "\${STARTUP_HEALTH_GRACE_SECONDS}" ]]; then
|
|
501
|
+
echo "[\$(date -u +%Y-%m-%dT%H:%M:%SZ)] launchd watchdog: waiting for startup health child=\${child_pid} age=\${child_age}s" >> "${LOG_DIR}/launchd-stderr.log"
|
|
502
|
+
missed_health_checks=0
|
|
503
|
+
else
|
|
504
|
+
missed_health_checks=\$((missed_health_checks + 1))
|
|
505
|
+
echo "[\$(date -u +%Y-%m-%dT%H:%M:%SZ)] launchd watchdog: missed health check \${missed_health_checks}/3 for child \${child_pid}" >> "${LOG_DIR}/launchd-stderr.log"
|
|
506
|
+
if [[ "\${missed_health_checks}" -ge 3 ]]; then
|
|
507
|
+
echo "[\$(date -u +%Y-%m-%dT%H:%M:%SZ)] launchd watchdog: restarting unhealthy child \${child_pid}" >> "${LOG_DIR}/launchd-stderr.log"
|
|
508
|
+
terminate_child
|
|
509
|
+
exit 1
|
|
510
|
+
fi
|
|
511
|
+
fi
|
|
512
|
+
fi
|
|
513
|
+
sleep 10
|
|
514
|
+
done
|
|
515
|
+
wait "\${child_pid}"
|
|
516
|
+
exit "\$?"
|
|
517
|
+
RUNNER
|
|
518
|
+
chmod +x "$LAUNCH_RUNNER"
|
|
519
|
+
|
|
520
|
+
cat > "$LAUNCH_AGENT_PATH" <<PLIST
|
|
521
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
522
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
523
|
+
<plist version="1.0">
|
|
524
|
+
<dict>
|
|
525
|
+
<key>Label</key>
|
|
526
|
+
<string>${LAUNCH_AGENT_LABEL}</string>
|
|
527
|
+
<key>ProgramArguments</key>
|
|
528
|
+
<array>
|
|
529
|
+
<string>${LAUNCH_RUNNER}</string>
|
|
530
|
+
</array>
|
|
531
|
+
<key>RunAtLoad</key>
|
|
532
|
+
<true/>
|
|
533
|
+
<key>KeepAlive</key>
|
|
534
|
+
<dict>
|
|
535
|
+
<key>SuccessfulExit</key>
|
|
536
|
+
<false/>
|
|
537
|
+
</dict>
|
|
538
|
+
<key>ThrottleInterval</key>
|
|
539
|
+
<integer>60</integer>
|
|
540
|
+
<key>StandardOutPath</key>
|
|
541
|
+
<string>${LOG_DIR}/launchd-stdout.log</string>
|
|
542
|
+
<key>StandardErrorPath</key>
|
|
543
|
+
<string>${LOG_DIR}/launchd-stderr.log</string>
|
|
544
|
+
</dict>
|
|
545
|
+
</plist>
|
|
546
|
+
PLIST
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
stop_legacy_service() {
|
|
550
|
+
if previous_service_loaded; then
|
|
551
|
+
launchctl bootout "gui/$(id -u)" "$PREVIOUS_LAUNCH_AGENT_PATH" || launchctl bootout "gui/$(id -u)/${PREVIOUS_LAUNCH_AGENT_LABEL}" || true
|
|
552
|
+
fi
|
|
553
|
+
if legacy_service_loaded; then
|
|
554
|
+
launchctl bootout "gui/$(id -u)" "$LEGACY_LAUNCH_AGENT_PATH" || launchctl bootout "gui/$(id -u)/${LEGACY_LAUNCH_AGENT_LABEL}" || true
|
|
555
|
+
fi
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
remove_legacy_service() {
|
|
559
|
+
stop_legacy_service
|
|
560
|
+
rm -f "$PREVIOUS_LAUNCH_AGENT_PATH"
|
|
561
|
+
rm -f "$LEGACY_LAUNCH_AGENT_PATH"
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
bootstrap_service() {
|
|
565
|
+
reset_launch_crash_guard
|
|
566
|
+
launchctl bootstrap "gui/$(id -u)" "$LAUNCH_AGENT_PATH"
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
prime_daemon_install_permissions() {
|
|
570
|
+
if [[ "$(uname -s)" != "Darwin" ]]; then
|
|
571
|
+
return 0
|
|
572
|
+
fi
|
|
573
|
+
|
|
574
|
+
echo "zterm daemon install permission preflight"
|
|
575
|
+
echo "- macOS file sync uses this daemon process to read/write user-selected paths."
|
|
576
|
+
echo "- Grant file access to Terminal/iTerm or the installed daemon runner when macOS prompts."
|
|
577
|
+
echo "- Screen Recording and remote window capture use zterm-daemon directly."
|
|
578
|
+
|
|
579
|
+
mkdir -p "$WTERM_HOME" "$UPLOAD_DIR" "$DOWNLOADS_DIR"
|
|
580
|
+
ZTERM_DAEMON_NATIVE="$NATIVE_DAEMON_BIN" "$NODE_BIN" - <<'NODE'
|
|
581
|
+
const { accessSync, constants, mkdirSync, rmSync, writeFileSync, unlinkSync } = require('node:fs');
|
|
582
|
+
const { execFileSync } = require('node:child_process');
|
|
583
|
+
const { join } = require('node:path');
|
|
584
|
+
const { homedir } = require('node:os');
|
|
585
|
+
|
|
586
|
+
const dirs = [
|
|
587
|
+
join(homedir(), '.zterm'),
|
|
588
|
+
join(homedir(), 'Downloads', 'zterm'),
|
|
589
|
+
];
|
|
590
|
+
|
|
591
|
+
for (const dir of dirs) {
|
|
592
|
+
mkdirSync(dir, { recursive: true });
|
|
593
|
+
accessSync(dir, constants.R_OK | constants.W_OK);
|
|
594
|
+
const probe = join(dir, '.zterm-permission-preflight');
|
|
595
|
+
writeFileSync(probe, 'ok\n');
|
|
596
|
+
unlinkSync(probe);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
try {
|
|
600
|
+
if (!process.env.ZTERM_DAEMON_NATIVE) {
|
|
601
|
+
throw new Error('installed ScreenCaptureKit capture binary is required');
|
|
602
|
+
}
|
|
603
|
+
execFileSync(process.env.ZTERM_DAEMON_NATIVE, ['--permission-probe'], {
|
|
604
|
+
stdio: 'pipe',
|
|
605
|
+
timeout: 180000,
|
|
606
|
+
});
|
|
607
|
+
} catch (error) {
|
|
608
|
+
const stderr = error && error.stderr ? String(error.stderr) : '';
|
|
609
|
+
const message = error && error.message ? String(error.message) : String(error);
|
|
610
|
+
const timedOut = /ETIMEDOUT|timed out/u.test(message);
|
|
611
|
+
console.error(timedOut
|
|
612
|
+
? 'ScreenCaptureKit permission was not granted before the 180s deadline.'
|
|
613
|
+
: 'ScreenCaptureKit permission preflight failed.');
|
|
614
|
+
console.error('Grant Screen Recording to ' + process.env.ZTERM_DAEMON_NATIVE + ' in System Settings -> Privacy & Security -> Screen & System Audio Recording by clicking + and adding that exact file. macOS 26 refused to show a grant dialog for this binary, so the add button is the supported path.');
|
|
615
|
+
if (stderr.trim()) console.error(stderr.trim());
|
|
616
|
+
if (message.trim()) console.error(message.trim());
|
|
617
|
+
process.exit(1);
|
|
618
|
+
}
|
|
619
|
+
NODE
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
start_service() {
|
|
623
|
+
if ! service_installed; then
|
|
624
|
+
echo "zterm autostart service not installed"
|
|
625
|
+
echo "run: zterm-daemon install-service"
|
|
626
|
+
return 1
|
|
627
|
+
fi
|
|
628
|
+
stop_direct >/dev/null 2>&1 || true
|
|
629
|
+
remove_legacy_service
|
|
630
|
+
write_launch_agent
|
|
631
|
+
if service_loaded; then
|
|
632
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" >/dev/null 2>&1 || true
|
|
633
|
+
wait_for_service_unloaded || {
|
|
634
|
+
echo "zterm autostart service failed to unload before start"
|
|
635
|
+
return 1
|
|
636
|
+
}
|
|
637
|
+
fi
|
|
638
|
+
bootstrap_service
|
|
639
|
+
if wait_for_service_ready; then
|
|
640
|
+
status_service
|
|
641
|
+
return 0
|
|
642
|
+
fi
|
|
643
|
+
echo "zterm autostart service unhealthy after start"
|
|
644
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" >/dev/null 2>&1 || true
|
|
645
|
+
return 1
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
stop_service() {
|
|
649
|
+
if ! service_installed; then
|
|
650
|
+
echo "zterm autostart service not installed"
|
|
651
|
+
return 0
|
|
652
|
+
fi
|
|
653
|
+
if service_loaded; then
|
|
654
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}"
|
|
655
|
+
fi
|
|
656
|
+
echo "zterm autostart service stopped: label=${LAUNCH_AGENT_LABEL}"
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
restart_service() {
|
|
660
|
+
if ! service_installed; then
|
|
661
|
+
echo "zterm autostart service not installed"
|
|
662
|
+
echo "run: zterm-daemon install-service"
|
|
663
|
+
return 1
|
|
664
|
+
fi
|
|
665
|
+
stop_direct >/dev/null 2>&1 || true
|
|
666
|
+
remove_legacy_service
|
|
667
|
+
write_launch_agent
|
|
668
|
+
if service_loaded; then
|
|
669
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}"
|
|
670
|
+
wait_for_service_unloaded || {
|
|
671
|
+
echo "zterm autostart service failed to unload before restart"
|
|
672
|
+
return 1
|
|
673
|
+
}
|
|
674
|
+
fi
|
|
675
|
+
bootstrap_service
|
|
676
|
+
if wait_for_service_ready; then
|
|
677
|
+
status_service
|
|
678
|
+
return 0
|
|
679
|
+
fi
|
|
680
|
+
echo "zterm autostart service unhealthy after restart"
|
|
681
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" >/dev/null 2>&1 || true
|
|
682
|
+
return 1
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
install_service() {
|
|
686
|
+
stop_direct >/dev/null 2>&1 || true
|
|
687
|
+
remove_legacy_service
|
|
688
|
+
write_launch_agent
|
|
689
|
+
prime_daemon_install_permissions
|
|
690
|
+
if service_loaded; then
|
|
691
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}"
|
|
692
|
+
wait_for_service_unloaded || {
|
|
693
|
+
echo "zterm autostart service failed to unload before install"
|
|
694
|
+
return 1
|
|
695
|
+
}
|
|
696
|
+
fi
|
|
697
|
+
bootstrap_service
|
|
698
|
+
echo "zterm autostart service installed"
|
|
699
|
+
echo "plist=${LAUNCH_AGENT_PATH}"
|
|
700
|
+
if wait_for_service_ready; then
|
|
701
|
+
status_service
|
|
702
|
+
return 0
|
|
703
|
+
fi
|
|
704
|
+
echo "zterm autostart service unhealthy after install"
|
|
705
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}" >/dev/null 2>&1 || true
|
|
706
|
+
return 1
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
uninstall_service() {
|
|
710
|
+
if service_loaded; then
|
|
711
|
+
launchctl bootout "gui/$(id -u)/${LAUNCH_AGENT_LABEL}"
|
|
712
|
+
fi
|
|
713
|
+
remove_legacy_service
|
|
714
|
+
rm -f "$LAUNCH_AGENT_PATH"
|
|
715
|
+
echo "zterm autostart service uninstalled"
|
|
716
|
+
echo "plist=${LAUNCH_AGENT_PATH}"
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
cmd="${1:-}"
|
|
720
|
+
if [[ "$cmd" == "--" ]]; then
|
|
721
|
+
shift
|
|
722
|
+
cmd="${1:-}"
|
|
723
|
+
fi
|
|
724
|
+
|
|
725
|
+
case "$cmd" in
|
|
726
|
+
run) run_foreground ;;
|
|
727
|
+
start) start_service ;;
|
|
728
|
+
status) status ;;
|
|
729
|
+
stop) stop_service ;;
|
|
730
|
+
restart) restart_service ;;
|
|
731
|
+
config) "$NODE_BIN" "$TERMINAL_CONFIG_COMMAND" daemon-config ;;
|
|
732
|
+
configure-relay) configure_relay "$@" ;;
|
|
733
|
+
install-service) install_service ;;
|
|
734
|
+
uninstall-service) uninstall_service ;;
|
|
735
|
+
service-status) status_service ;;
|
|
736
|
+
""|-h|--help|help) usage ;;
|
|
737
|
+
*)
|
|
738
|
+
echo "unknown command: $cmd" >&2
|
|
739
|
+
usage >&2
|
|
740
|
+
exit 1
|
|
741
|
+
;;
|
|
742
|
+
esac
|