@juspay/shooter 1.0.0 → 1.2.0
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/.claude/hooks/notifier.cjs +117 -33
- package/.claude/settings.json +14 -14
- package/README.md +116 -84
- package/bin/shooter.cjs +471 -102
- package/build/client/_app/immutable/assets/{0.CM9Hl6d-.css → 0.BhZOCxO4.css} +1 -1
- package/build/client/_app/immutable/assets/0.BhZOCxO4.css.br +0 -0
- package/build/client/_app/immutable/assets/0.BhZOCxO4.css.gz +0 -0
- package/build/client/_app/immutable/assets/1.BYutk3aU.css +1 -0
- package/build/client/_app/immutable/assets/1.BYutk3aU.css.br +0 -0
- package/build/client/_app/immutable/assets/1.BYutk3aU.css.gz +0 -0
- package/build/client/_app/immutable/assets/2.CAShZ7lQ.css.gz +0 -0
- package/build/client/_app/immutable/assets/3.DGDHCVnW.css +1 -0
- package/build/client/_app/immutable/assets/3.DGDHCVnW.css.br +0 -0
- package/build/client/_app/immutable/assets/3.DGDHCVnW.css.gz +0 -0
- package/build/client/_app/immutable/assets/4.BFUut--w.css +1 -0
- package/build/client/_app/immutable/assets/4.BFUut--w.css.br +0 -0
- package/build/client/_app/immutable/assets/4.BFUut--w.css.gz +0 -0
- package/build/client/_app/immutable/assets/5.BTOx7yt7.css +1 -0
- package/build/client/_app/immutable/assets/5.BTOx7yt7.css.br +0 -0
- package/build/client/_app/immutable/assets/5.BTOx7yt7.css.gz +0 -0
- package/build/client/_app/immutable/assets/6.eZGZN-BF.css +1 -0
- package/build/client/_app/immutable/assets/6.eZGZN-BF.css.br +0 -0
- package/build/client/_app/immutable/assets/6.eZGZN-BF.css.gz +0 -0
- package/build/client/_app/immutable/assets/7.DwS5ZHBh.css +1 -0
- package/build/client/_app/immutable/assets/7.DwS5ZHBh.css.br +0 -0
- package/build/client/_app/immutable/assets/7.DwS5ZHBh.css.gz +0 -0
- package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css +1 -0
- package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css.br +0 -0
- package/build/client/_app/immutable/assets/ChatView.CwWbzIL-.css.gz +0 -0
- package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css +1 -0
- package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css.br +0 -0
- package/build/client/_app/immutable/assets/Phone.FQEfwCX2.css.gz +0 -0
- package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css +1 -0
- package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css.br +0 -0
- package/build/client/_app/immutable/assets/markdown.Dc-OSJWY.css.gz +0 -0
- package/build/client/_app/immutable/assets/xterm.DFuMZ0ql.css.gz +0 -0
- package/build/client/_app/immutable/chunks/B-K5Sh65.js +1 -0
- package/build/client/_app/immutable/chunks/B-K5Sh65.js.br +0 -0
- package/build/client/_app/immutable/chunks/B-K5Sh65.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B5NAKyil.js +20 -0
- package/build/client/_app/immutable/chunks/B5NAKyil.js.br +0 -0
- package/build/client/_app/immutable/chunks/B5NAKyil.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B8XegpSE.js +1 -0
- package/build/client/_app/immutable/chunks/B8XegpSE.js.br +0 -0
- package/build/client/_app/immutable/chunks/B8XegpSE.js.gz +0 -0
- package/build/client/_app/immutable/chunks/B8zoBsv3.js +6 -0
- package/build/client/_app/immutable/chunks/B8zoBsv3.js.br +0 -0
- package/build/client/_app/immutable/chunks/B8zoBsv3.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BLszSzTT.js +1 -0
- package/build/client/_app/immutable/chunks/BLszSzTT.js.br +0 -0
- package/build/client/_app/immutable/chunks/BLszSzTT.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BOYo8yTr.js +1 -0
- package/build/client/_app/immutable/chunks/BOYo8yTr.js.br +0 -0
- package/build/client/_app/immutable/chunks/BOYo8yTr.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BTGVxaYV.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BYqGCrTe.js +1 -0
- package/build/client/_app/immutable/chunks/BYqGCrTe.js.br +0 -0
- package/build/client/_app/immutable/chunks/BYqGCrTe.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BlxrFPDK.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Bu1aqm5j.js +1 -0
- package/build/client/_app/immutable/chunks/Bu1aqm5j.js.br +0 -0
- package/build/client/_app/immutable/chunks/Bu1aqm5j.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C4mLaWWx.js +1 -0
- package/build/client/_app/immutable/chunks/C4mLaWWx.js.br +0 -0
- package/build/client/_app/immutable/chunks/C4mLaWWx.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CQjSATpv.js +61 -0
- package/build/client/_app/immutable/chunks/CQjSATpv.js.br +0 -0
- package/build/client/_app/immutable/chunks/CQjSATpv.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CSoRdFvv.js +1 -0
- package/build/client/_app/immutable/chunks/CSoRdFvv.js.br +0 -0
- package/build/client/_app/immutable/chunks/CSoRdFvv.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CZHsSL_X.js +1 -0
- package/build/client/_app/immutable/chunks/CZHsSL_X.js.br +0 -0
- package/build/client/_app/immutable/chunks/CZHsSL_X.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DLu6yJIZ.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DSU1n5N_.js +1 -0
- package/build/client/_app/immutable/chunks/DSU1n5N_.js.br +0 -0
- package/build/client/_app/immutable/chunks/DSU1n5N_.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DVkn4r72.js +1 -0
- package/build/client/_app/immutable/chunks/DVkn4r72.js.br +0 -0
- package/build/client/_app/immutable/chunks/DVkn4r72.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DjsDGxCa.js +41 -0
- package/build/client/_app/immutable/chunks/DjsDGxCa.js.br +0 -0
- package/build/client/_app/immutable/chunks/DjsDGxCa.js.gz +0 -0
- package/build/client/_app/immutable/chunks/PPVm8Dsz.js.gz +0 -0
- package/build/client/_app/immutable/chunks/UJOiqIYE.js +1 -0
- package/build/client/_app/immutable/chunks/UJOiqIYE.js.br +0 -0
- package/build/client/_app/immutable/chunks/UJOiqIYE.js.gz +0 -0
- package/build/client/_app/immutable/chunks/r0JawsZc.js +2 -0
- package/build/client/_app/immutable/chunks/r0JawsZc.js.br +0 -0
- package/build/client/_app/immutable/chunks/r0JawsZc.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.Z3zMnuSx.js +2 -0
- package/build/client/_app/immutable/entry/app.Z3zMnuSx.js.br +0 -0
- package/build/client/_app/immutable/entry/app.Z3zMnuSx.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.Dd-gIP4y.js +1 -0
- package/build/client/_app/immutable/entry/start.Dd-gIP4y.js.br +2 -0
- package/build/client/_app/immutable/entry/start.Dd-gIP4y.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.D2YR8tTD.js +1 -0
- package/build/client/_app/immutable/nodes/0.D2YR8tTD.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.D2YR8tTD.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.B3m6rO4C.js +1 -0
- package/build/client/_app/immutable/nodes/1.B3m6rO4C.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.B3m6rO4C.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.CyRB2euU.js +1 -0
- package/build/client/_app/immutable/nodes/2.CyRB2euU.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CyRB2euU.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.3yohCM25.js +3 -0
- package/build/client/_app/immutable/nodes/3.3yohCM25.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.3yohCM25.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.DEAcwl7l.js +1 -0
- package/build/client/_app/immutable/nodes/4.DEAcwl7l.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.DEAcwl7l.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.C6bLGWQR.js +4 -0
- package/build/client/_app/immutable/nodes/5.C6bLGWQR.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.C6bLGWQR.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.ByTzlA2D.js +2 -0
- package/build/client/_app/immutable/nodes/6.ByTzlA2D.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.ByTzlA2D.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.BPMfwzd2.js +2 -0
- package/build/client/_app/immutable/nodes/7.BPMfwzd2.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.BPMfwzd2.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/client/favicon.svg.gz +0 -0
- package/build/client/manifest.json +13 -0
- package/build/client/manifest.json.br +0 -0
- package/build/client/manifest.json.gz +0 -0
- package/build/pty-holder.cjs +37 -8
- package/build/server/chunks/0-Vk38tI2J.js +9 -0
- package/build/server/chunks/0-Vk38tI2J.js.map +1 -0
- package/build/server/chunks/1-BvYQX5MR.js +9 -0
- package/build/server/chunks/1-BvYQX5MR.js.map +1 -0
- package/build/server/chunks/2-Cl7R4Qk2.js +9 -0
- package/build/server/chunks/2-Cl7R4Qk2.js.map +1 -0
- package/build/server/chunks/3-Ck7ewhOX.js +9 -0
- package/build/server/chunks/3-Ck7ewhOX.js.map +1 -0
- package/build/server/chunks/4-CnDeRm2Z.js +9 -0
- package/build/server/chunks/4-CnDeRm2Z.js.map +1 -0
- package/build/server/chunks/5-IxitzEvN.js +9 -0
- package/build/server/chunks/5-IxitzEvN.js.map +1 -0
- package/build/server/chunks/6-CyZ3r1iS.js +9 -0
- package/build/server/chunks/6-CyZ3r1iS.js.map +1 -0
- package/build/server/chunks/7-BmI7du46.js +9 -0
- package/build/server/chunks/7-BmI7du46.js.map +1 -0
- package/build/server/chunks/Button-Cs1aE6ka.js +80 -0
- package/build/server/chunks/Button-Cs1aE6ka.js.map +1 -0
- package/build/server/chunks/EmptyState-DDFH1K8g.js +26 -0
- package/build/server/chunks/EmptyState-DDFH1K8g.js.map +1 -0
- package/build/server/chunks/Icon-CEUrotA6.js +36 -0
- package/build/server/chunks/Icon-CEUrotA6.js.map +1 -0
- package/build/server/chunks/Shimmer-DB8W1zt6.js +10 -0
- package/build/server/chunks/Shimmer-DB8W1zt6.js.map +1 -0
- package/build/server/chunks/_error.svelte-uCOJNxvr.js +39 -0
- package/build/server/chunks/_error.svelte-uCOJNxvr.js.map +1 -0
- package/build/server/chunks/_layout.svelte-CtWmEJwe.js +56 -0
- package/build/server/chunks/_layout.svelte-CtWmEJwe.js.map +1 -0
- package/build/server/chunks/_page.svelte-BcZaKdX9.js +45 -0
- package/build/server/chunks/_page.svelte-BcZaKdX9.js.map +1 -0
- package/build/server/chunks/_page.svelte-BdYynOck.js +85 -0
- package/build/server/chunks/_page.svelte-BdYynOck.js.map +1 -0
- package/build/server/chunks/_page.svelte-BgevQjq1.js +101 -0
- package/build/server/chunks/_page.svelte-BgevQjq1.js.map +1 -0
- package/build/server/chunks/_page.svelte-CVq6tRb3.js +550 -0
- package/build/server/chunks/_page.svelte-CVq6tRb3.js.map +1 -0
- package/build/server/chunks/_page.svelte-CxWcQ0Am.js +651 -0
- package/build/server/chunks/_page.svelte-CxWcQ0Am.js.map +1 -0
- package/build/server/chunks/_page.svelte-DO4oa_LY.js +44 -0
- package/build/server/chunks/_page.svelte-DO4oa_LY.js.map +1 -0
- package/build/server/chunks/{_server.ts-CbDRDIoP.js → _server.ts-BStnNIcq.js} +9 -11
- package/build/server/chunks/_server.ts-BStnNIcq.js.map +1 -0
- package/build/server/chunks/{_server.ts-DRVbgm6k.js → _server.ts-CAxsWKvS.js} +22 -25
- package/build/server/chunks/_server.ts-CAxsWKvS.js.map +1 -0
- package/build/server/chunks/{_server.ts-CPa6DgIt.js → _server.ts-COu0vNpd.js} +6 -6
- package/build/server/chunks/_server.ts-COu0vNpd.js.map +1 -0
- package/build/server/chunks/{_server.ts-C29xzfaw.js → _server.ts-CTpcLUH8.js} +10 -10
- package/build/server/chunks/_server.ts-CTpcLUH8.js.map +1 -0
- package/build/server/chunks/{_server.ts-D4MNi4cD.js → _server.ts-Cf84YIaW.js} +3 -3
- package/build/server/chunks/{_server.ts-D4MNi4cD.js.map → _server.ts-Cf84YIaW.js.map} +1 -1
- package/build/server/chunks/{_server.ts-BL2FGb5Z.js → _server.ts-Ch-6iOHp.js} +99 -53
- package/build/server/chunks/_server.ts-Ch-6iOHp.js.map +1 -0
- package/build/server/chunks/_server.ts-CtH0dhUp.js +71 -0
- package/build/server/chunks/_server.ts-CtH0dhUp.js.map +1 -0
- package/build/server/chunks/_server.ts-DB_Kg97c.js +73 -0
- package/build/server/chunks/_server.ts-DB_Kg97c.js.map +1 -0
- package/build/server/chunks/{_server.ts-DfajWaqh.js → _server.ts-DV8zTCF9.js} +7 -9
- package/build/server/chunks/_server.ts-DV8zTCF9.js.map +1 -0
- package/build/server/chunks/_server.ts-DYpJImqd.js +99 -0
- package/build/server/chunks/_server.ts-DYpJImqd.js.map +1 -0
- package/build/server/chunks/{_server.ts-ColfDHW8.js → _server.ts-DYvb9ijZ.js} +21 -10
- package/build/server/chunks/_server.ts-DYvb9ijZ.js.map +1 -0
- package/build/server/chunks/{_server.ts-Cv_OrRuL.js → _server.ts-Deok2y88.js} +209 -34
- package/build/server/chunks/_server.ts-Deok2y88.js.map +1 -0
- package/build/server/chunks/{_server.ts-y9-WYDMa.js → _server.ts-WhTJBEJy.js} +5 -4
- package/build/server/chunks/{_server.ts-y9-WYDMa.js.map → _server.ts-WhTJBEJy.js.map} +1 -1
- package/build/server/chunks/{_server.ts-BjOJsoy4.js → _server.ts-XzT2UHM1.js} +6 -5
- package/build/server/chunks/_server.ts-XzT2UHM1.js.map +1 -0
- package/build/server/chunks/{_server.ts-BgdjBZco.js → _server.ts-tSpgyl1D.js} +7 -5
- package/build/server/chunks/_server.ts-tSpgyl1D.js.map +1 -0
- package/build/server/chunks/{_server.ts-BihKSdj_.js → _server.ts-vekTmWAx.js} +8 -8
- package/build/server/chunks/_server.ts-vekTmWAx.js.map +1 -0
- package/build/server/chunks/{auth-CEgFis71.js → auth-DeCdZ83n.js} +2 -2
- package/build/server/chunks/{auth-CEgFis71.js.map → auth-DeCdZ83n.js.map} +1 -1
- package/build/server/chunks/client-BdGHe_hY.js +25 -0
- package/build/server/chunks/client-BdGHe_hY.js.map +1 -0
- package/build/server/chunks/client2-CCBGA-2V.js +7 -0
- package/build/server/chunks/client2-CCBGA-2V.js.map +1 -0
- package/build/server/chunks/error-DDXB3duW.js +12 -0
- package/build/server/chunks/error-DDXB3duW.js.map +1 -0
- package/build/server/chunks/{exports-CJ0Q5XmL.js → index-DwaY1cAm.js} +1111 -1634
- package/build/server/chunks/index-DwaY1cAm.js.map +1 -0
- package/build/server/chunks/index-server-CrDaL06Y.js +9 -0
- package/build/server/chunks/index-server-CrDaL06Y.js.map +1 -0
- package/build/server/chunks/index2-CgclKpUj.js +58 -0
- package/build/server/chunks/index2-CgclKpUj.js.map +1 -0
- package/build/server/chunks/{library-apns-BHxLmuIx.js → library-apns-BqJbvSKh.js} +4 -4
- package/build/server/chunks/library-apns-BqJbvSKh.js.map +1 -0
- package/build/server/chunks/markdown-W_mTBct0.js +8 -0
- package/build/server/chunks/markdown-W_mTBct0.js.map +1 -0
- package/build/server/chunks/opencode-db-path-DcfhJtJy.js +15 -0
- package/build/server/chunks/opencode-db-path-DcfhJtJy.js.map +1 -0
- package/build/server/chunks/{pty-manager-C0FhBiVq.js → pty-manager-BQVB7IVj.js} +155 -326
- package/build/server/chunks/pty-manager-BQVB7IVj.js.map +1 -0
- package/build/server/chunks/root-DDSnEAZv.js +1171 -0
- package/build/server/chunks/root-DDSnEAZv.js.map +1 -0
- package/build/server/chunks/{shared-server-BDY8jh20.js → shared-server-sSGG17Df.js} +2 -3
- package/build/server/chunks/{shared-server-BDY8jh20.js.map → shared-server-sSGG17Df.js.map} +1 -1
- package/build/server/chunks/state.svelte-hBbXlUak.js +11 -0
- package/build/server/chunks/state.svelte-hBbXlUak.js.map +1 -0
- package/build/server/chunks/stores-DHNzYNpX.js +28 -0
- package/build/server/chunks/stores-DHNzYNpX.js.map +1 -0
- package/build/server/index.js +1085 -2242
- package/build/server/index.js.map +1 -1
- package/build/server/manifest.js +39 -25
- package/build/server/manifest.js.map +1 -1
- package/package.json +32 -9
- package/scripts/fix-generated-types.sh +37 -0
- package/scripts/homebrew/shooter.rb +51 -0
- package/scripts/install.sh +348 -186
- package/scripts/setup.cjs +215 -45
- package/server.ts +114 -71
- package/src/app.css +12 -3
- package/src/app.d.ts +13 -20
- package/src/app.html +3 -2
- package/src/generated/types/API.ts +280 -0
- package/src/generated/types/APN.ts +186 -203
- package/src/generated/types/CLI.ts +18 -25
- package/src/generated/types/Client.ts +589 -0
- package/src/generated/types/Config.ts +53 -0
- package/src/generated/types/Holder.ts +638 -0
- package/src/generated/types/JWT.ts +39 -50
- package/src/generated/types/Notification.ts +426 -0
- package/src/generated/types/OpenCode.ts +356 -0
- package/src/generated/types/Sessions.ts +570 -0
- package/src/generated/types/Terminal.ts +2184 -2071
- package/src/generated/types/WsProtocol.ts +2004 -0
- package/src/generated/types/index.ts +9 -3
- package/src/lib/env.ts +29 -0
- package/src/lib/modules/client/common/cache.ts +10 -2
- package/src/lib/modules/client/common/config-guard.ts +37 -5
- package/src/lib/modules/client/common/error.ts +10 -0
- package/src/lib/modules/client/common/index.ts +6 -5
- package/src/lib/modules/client/common/markdown.ts +22 -1
- package/src/lib/modules/client/common/native-bridge.ts +28 -20
- package/src/lib/modules/client/common/time.ts +13 -11
- package/src/lib/modules/client/terminal/ChatView.svelte +354 -74
- package/src/lib/modules/client/terminal/CommandPalette.svelte +3 -2
- package/src/lib/modules/client/terminal/ConnectionStatus.svelte +7 -1
- package/src/lib/modules/client/terminal/LaunchSheet.svelte +147 -84
- package/src/lib/modules/client/terminal/QuickKeys.svelte +3 -1
- package/src/lib/modules/client/terminal/ShortcutsHelp.svelte +2 -5
- package/src/lib/modules/client/terminal/keyboard-shortcuts.ts +27 -24
- package/src/lib/modules/client/terminal/xterm-wrapper.ts +74 -45
- package/src/lib/modules/server/apn/library-apns.ts +3 -2
- package/src/lib/modules/server/apn/notification-history.ts +2 -13
- package/src/lib/modules/server/apn/notification-sessions.ts +3 -13
- package/src/lib/modules/server/apn/pending-requests.ts +3 -8
- package/src/lib/modules/server/apn/types.ts +5 -4
- package/src/lib/modules/server/cli/index.ts +3 -2
- package/src/lib/modules/server/fcm/fcm-service.ts +8 -6
- package/src/lib/modules/server/sessions/jsonl-parser.ts +3 -3
- package/src/lib/modules/server/sessions/jsonl-reader.ts +86 -26
- package/src/lib/modules/server/sessions/opencode-db-path.ts +26 -0
- package/src/lib/modules/server/sessions/opencode-reader.ts +13 -15
- package/src/lib/modules/server/sessions/process-detector.ts +103 -0
- package/src/lib/modules/server/sessions/types.ts +11 -22
- package/src/lib/modules/server/terminal/holder-client.ts +272 -248
- package/src/lib/modules/server/terminal/opencode-watcher.ts +547 -556
- package/src/lib/modules/server/terminal/pty-holder.cjs +37 -8
- package/src/lib/modules/server/terminal/pty-manager.ts +157 -115
- package/src/lib/modules/server/terminal/session-watcher.ts +6 -4
- package/src/lib/modules/server/terminal/terminal-store.ts +131 -128
- package/src/lib/modules/server/utils/error.ts +9 -0
- package/src/lib/modules/server/ws/events-handler.ts +12 -6
- package/src/lib/modules/server/ws/keepalive.ts +86 -69
- package/src/lib/modules/server/ws/server.ts +43 -37
- package/src/lib/modules/server/ws/session-handler.ts +332 -147
- package/src/lib/modules/server/ws/terminal-handler.ts +29 -17
- package/src/lib/modules/server/ws/ticket-store.ts +29 -26
- package/src/lib/theme.css +30 -0
- package/src/lib/types/config.ts +1 -6
- package/src/routes/+error.svelte +94 -0
- package/src/routes/+layout.svelte +66 -31
- package/src/routes/+page.svelte +25 -22
- package/src/routes/api/debug/+server.ts +3 -1
- package/src/routes/api/device-token/+server.ts +60 -60
- package/src/routes/api/health/+server.ts +81 -73
- package/src/routes/api/notify/+server.ts +115 -68
- package/src/routes/api/qr-config/+server.ts +30 -32
- package/src/routes/api/response/+server.ts +9 -4
- package/src/routes/api/sessions/+server.ts +15 -5
- package/src/routes/api/sessions/connect/+server.ts +125 -0
- package/src/routes/api/sessions/detect/+server.ts +27 -0
- package/src/routes/api/terminals/+server.ts +26 -24
- package/src/routes/api/terminals/[id]/+server.ts +13 -7
- package/src/routes/api/terminals/[id]/paste-image/+server.ts +54 -52
- package/src/routes/api/terminals/[id]/resize/+server.ts +6 -3
- package/src/routes/api/webhook/+server.ts +8 -10
- package/src/routes/api/ws-status/+server.ts +7 -5
- package/src/routes/api/ws-ticket/+server.ts +42 -41
- package/src/routes/config/+page.svelte +149 -75
- package/src/routes/project/+page.svelte +165 -35
- package/src/routes/session/[id]/+page.svelte +479 -283
- package/src/routes/terminals/+page.svelte +58 -45
- package/src/routes/terminals/[id]/+page.svelte +223 -91
- package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.br +0 -0
- package/build/client/_app/immutable/assets/0.CM9Hl6d-.css.gz +0 -0
- package/build/client/_app/immutable/assets/3.C0uFg0IS.css +0 -1
- package/build/client/_app/immutable/assets/3.C0uFg0IS.css.br +0 -0
- package/build/client/_app/immutable/assets/3.C0uFg0IS.css.gz +0 -0
- package/build/client/_app/immutable/assets/4.cJuCkJKZ.css +0 -1
- package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.br +0 -0
- package/build/client/_app/immutable/assets/4.cJuCkJKZ.css.gz +0 -0
- package/build/client/_app/immutable/assets/5.DRjApZQW.css +0 -1
- package/build/client/_app/immutable/assets/5.DRjApZQW.css.br +0 -0
- package/build/client/_app/immutable/assets/5.DRjApZQW.css.gz +0 -0
- package/build/client/_app/immutable/assets/6.AraZrY8I.css +0 -1
- package/build/client/_app/immutable/assets/6.AraZrY8I.css.br +0 -0
- package/build/client/_app/immutable/assets/6.AraZrY8I.css.gz +0 -0
- package/build/client/_app/immutable/assets/7.BCJ1IuMx.css +0 -1
- package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.br +0 -0
- package/build/client/_app/immutable/assets/7.BCJ1IuMx.css.gz +0 -0
- package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css +0 -1
- package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.br +0 -0
- package/build/client/_app/immutable/assets/ChatView.CsdBAOKx.css.gz +0 -0
- package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css +0 -1
- package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.br +0 -0
- package/build/client/_app/immutable/assets/markdown.B0b5w2tq.css.gz +0 -0
- package/build/client/_app/immutable/chunks/BNJphC1q.js +0 -56
- package/build/client/_app/immutable/chunks/BNJphC1q.js.br +0 -0
- package/build/client/_app/immutable/chunks/BNJphC1q.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Bvk7mfPM.js +0 -1
- package/build/client/_app/immutable/chunks/Bvk7mfPM.js.br +0 -0
- package/build/client/_app/immutable/chunks/Bvk7mfPM.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CAokzuPQ.js +0 -1
- package/build/client/_app/immutable/chunks/CAokzuPQ.js.br +0 -0
- package/build/client/_app/immutable/chunks/CAokzuPQ.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CGLrx-H5.js +0 -1
- package/build/client/_app/immutable/chunks/CGLrx-H5.js.br +0 -0
- package/build/client/_app/immutable/chunks/CGLrx-H5.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CgCpWzEA.js +0 -1
- package/build/client/_app/immutable/chunks/CgCpWzEA.js.br +0 -0
- package/build/client/_app/immutable/chunks/CgCpWzEA.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Cjwk_cGO.js +0 -6
- package/build/client/_app/immutable/chunks/Cjwk_cGO.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cjwk_cGO.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CtQ8EED1.js +0 -11
- package/build/client/_app/immutable/chunks/CtQ8EED1.js.br +0 -0
- package/build/client/_app/immutable/chunks/CtQ8EED1.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DERQCisl.js +0 -1
- package/build/client/_app/immutable/chunks/DERQCisl.js.br +0 -0
- package/build/client/_app/immutable/chunks/DERQCisl.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DKrg8TQs.js +0 -1
- package/build/client/_app/immutable/chunks/DKrg8TQs.js.br +0 -0
- package/build/client/_app/immutable/chunks/DKrg8TQs.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Dkkpz_4D.js +0 -126
- package/build/client/_app/immutable/chunks/Dkkpz_4D.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dkkpz_4D.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DoczjQhA.js +0 -1
- package/build/client/_app/immutable/chunks/DoczjQhA.js.br +0 -0
- package/build/client/_app/immutable/chunks/DoczjQhA.js.gz +0 -0
- package/build/client/_app/immutable/chunks/RpcNruLP.js +0 -2
- package/build/client/_app/immutable/chunks/RpcNruLP.js.br +0 -0
- package/build/client/_app/immutable/chunks/RpcNruLP.js.gz +0 -0
- package/build/client/_app/immutable/chunks/a-St0Zwo.js +0 -1
- package/build/client/_app/immutable/chunks/a-St0Zwo.js.br +0 -0
- package/build/client/_app/immutable/chunks/a-St0Zwo.js.gz +0 -0
- package/build/client/_app/immutable/chunks/bo70OQUZ.js +0 -1
- package/build/client/_app/immutable/chunks/bo70OQUZ.js.br +0 -0
- package/build/client/_app/immutable/chunks/bo70OQUZ.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.QvGgdvTI.js +0 -2
- package/build/client/_app/immutable/entry/app.QvGgdvTI.js.br +0 -0
- package/build/client/_app/immutable/entry/app.QvGgdvTI.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.BntDNRMC.js +0 -1
- package/build/client/_app/immutable/entry/start.BntDNRMC.js.br +0 -0
- package/build/client/_app/immutable/entry/start.BntDNRMC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js +0 -1
- package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.CzkdvJ7j.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.MG1QhfrI.js +0 -1
- package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.MG1QhfrI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.B4MlOSh6.js +0 -1
- package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.B4MlOSh6.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.DIwYkjDn.js +0 -3
- package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.DIwYkjDn.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.D-cIe70D.js +0 -1
- package/build/client/_app/immutable/nodes/4.D-cIe70D.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.D-cIe70D.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.D7zPRe3L.js +0 -1
- package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.D7zPRe3L.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.BB7QE48r.js +0 -2
- package/build/client/_app/immutable/nodes/6.BB7QE48r.js.br +0 -0
- package/build/client/_app/immutable/nodes/6.BB7QE48r.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.D8mqsrZG.js +0 -2
- package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.D8mqsrZG.js.gz +0 -0
- package/build/client/manifest.webmanifest +0 -1
- package/build/client/registerSW.js +0 -1
- package/build/client/registerSW.js.br +0 -0
- package/build/client/registerSW.js.gz +0 -0
- package/build/client/sw.js +0 -222
- package/build/client/sw.js.br +0 -0
- package/build/client/sw.js.gz +0 -0
- package/build/client/workbox-5119daf5.js +0 -3395
- package/build/client/workbox-5119daf5.js.br +0 -0
- package/build/client/workbox-5119daf5.js.gz +0 -0
- package/build/server/chunks/0-q2IUp76Y.js +0 -9
- package/build/server/chunks/0-q2IUp76Y.js.map +0 -1
- package/build/server/chunks/1-CU50G5wZ.js +0 -9
- package/build/server/chunks/1-CU50G5wZ.js.map +0 -1
- package/build/server/chunks/2-D01t9s8T.js +0 -9
- package/build/server/chunks/2-D01t9s8T.js.map +0 -1
- package/build/server/chunks/3-5PUQ04wC.js +0 -9
- package/build/server/chunks/3-5PUQ04wC.js.map +0 -1
- package/build/server/chunks/4-e7gywnSG.js +0 -9
- package/build/server/chunks/4-e7gywnSG.js.map +0 -1
- package/build/server/chunks/5-CA1SA6KZ.js +0 -9
- package/build/server/chunks/5-CA1SA6KZ.js.map +0 -1
- package/build/server/chunks/6-71H221sV.js +0 -9
- package/build/server/chunks/6-71H221sV.js.map +0 -1
- package/build/server/chunks/7-Bo-vmdyz.js +0 -9
- package/build/server/chunks/7-Bo-vmdyz.js.map +0 -1
- package/build/server/chunks/_layout.svelte-SFHOxs74.js +0 -132
- package/build/server/chunks/_layout.svelte-SFHOxs74.js.map +0 -1
- package/build/server/chunks/_page.svelte-B4w-2wD-.js +0 -120
- package/build/server/chunks/_page.svelte-B4w-2wD-.js.map +0 -1
- package/build/server/chunks/_page.svelte-B_qAXjkh.js +0 -213
- package/build/server/chunks/_page.svelte-B_qAXjkh.js.map +0 -1
- package/build/server/chunks/_page.svelte-CsF1_TRG.js +0 -50
- package/build/server/chunks/_page.svelte-CsF1_TRG.js.map +0 -1
- package/build/server/chunks/_page.svelte-DJC6U-P0.js +0 -68
- package/build/server/chunks/_page.svelte-DJC6U-P0.js.map +0 -1
- package/build/server/chunks/_page.svelte-DQ6HBtsz.js +0 -407
- package/build/server/chunks/_page.svelte-DQ6HBtsz.js.map +0 -1
- package/build/server/chunks/_page.svelte-LbhhjP21.js +0 -148
- package/build/server/chunks/_page.svelte-LbhhjP21.js.map +0 -1
- package/build/server/chunks/_server.ts-BL2FGb5Z.js.map +0 -1
- package/build/server/chunks/_server.ts-BgdjBZco.js.map +0 -1
- package/build/server/chunks/_server.ts-BihKSdj_.js.map +0 -1
- package/build/server/chunks/_server.ts-BjOJsoy4.js.map +0 -1
- package/build/server/chunks/_server.ts-C29xzfaw.js.map +0 -1
- package/build/server/chunks/_server.ts-CPa6DgIt.js.map +0 -1
- package/build/server/chunks/_server.ts-CbDRDIoP.js.map +0 -1
- package/build/server/chunks/_server.ts-Cl1OEWL4.js +0 -54
- package/build/server/chunks/_server.ts-Cl1OEWL4.js.map +0 -1
- package/build/server/chunks/_server.ts-ColfDHW8.js.map +0 -1
- package/build/server/chunks/_server.ts-Cv_OrRuL.js.map +0 -1
- package/build/server/chunks/_server.ts-DRVbgm6k.js.map +0 -1
- package/build/server/chunks/_server.ts-DfajWaqh.js.map +0 -1
- package/build/server/chunks/client-CxCatAKr.js +0 -255
- package/build/server/chunks/client-CxCatAKr.js.map +0 -1
- package/build/server/chunks/error.svelte-BqdwMWdK.js +0 -26
- package/build/server/chunks/error.svelte-BqdwMWdK.js.map +0 -1
- package/build/server/chunks/exports-CJ0Q5XmL.js.map +0 -1
- package/build/server/chunks/index2-DAxIoAO-.js +0 -36
- package/build/server/chunks/index2-DAxIoAO-.js.map +0 -1
- package/build/server/chunks/jsonl-parser-dmZU_Hyu.js +0 -137
- package/build/server/chunks/jsonl-parser-dmZU_Hyu.js.map +0 -1
- package/build/server/chunks/library-apns-BHxLmuIx.js.map +0 -1
- package/build/server/chunks/markdown-Bxrl3cCF.js +0 -1241
- package/build/server/chunks/markdown-Bxrl3cCF.js.map +0 -1
- package/build/server/chunks/pty-manager-C0FhBiVq.js.map +0 -1
- package/build/server/chunks/stores-D0HorpgL.js +0 -36
- package/build/server/chunks/stores-D0HorpgL.js.map +0 -1
|
@@ -1,2736 +1,2849 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type SessionSource,
|
|
3
|
+
decodeSessionSource,
|
|
4
|
+
type PermissionDecision,
|
|
5
|
+
decodePermissionDecision,
|
|
6
|
+
} from './index';
|
|
7
|
+
import {
|
|
8
|
+
isJSON,
|
|
9
|
+
decodeString,
|
|
10
|
+
_decodeString,
|
|
11
|
+
decodeArray,
|
|
12
|
+
_decodeArray,
|
|
13
|
+
decodeNumber,
|
|
14
|
+
_decodeNumber,
|
|
15
|
+
decodeBoolean,
|
|
16
|
+
_decodeBoolean,
|
|
17
|
+
} from 'type-decoder';
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
|
-
* @type {
|
|
5
|
-
* @description
|
|
20
|
+
* @type { TerminalStatus }
|
|
21
|
+
* @description Lifecycle status of a terminal session
|
|
22
|
+
*/
|
|
23
|
+
export type TerminalStatus = 'running' | 'exited' | 'orphaned';
|
|
24
|
+
|
|
25
|
+
export function decodeTerminalStatus(rawInput: unknown): TerminalStatus | null {
|
|
26
|
+
switch (rawInput) {
|
|
27
|
+
case 'running':
|
|
28
|
+
case 'exited':
|
|
29
|
+
case 'orphaned':
|
|
30
|
+
return rawInput;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function _decodeTerminalStatus(rawInput: unknown): TerminalStatus | undefined {
|
|
36
|
+
switch (rawInput) {
|
|
37
|
+
case 'running':
|
|
38
|
+
case 'exited':
|
|
39
|
+
case 'orphaned':
|
|
40
|
+
return rawInput;
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @type { ManagedTerminalInfo }
|
|
47
|
+
* @description Serializable info about a managed terminal session (excludes runtime handles like PTY, watchers, client sets)
|
|
6
48
|
*/
|
|
7
|
-
export
|
|
49
|
+
export type ManagedTerminalInfo = {
|
|
8
50
|
/**
|
|
9
|
-
* @description
|
|
51
|
+
* @description Unique terminal identifier (e.g. "term_a1b2c3")
|
|
52
|
+
* @type { string }
|
|
53
|
+
* @memberof ManagedTerminalInfo
|
|
54
|
+
*/
|
|
55
|
+
id: string;
|
|
56
|
+
/**
|
|
57
|
+
* @description The command that was launched (e.g. "zsh", "claude", "opencode")
|
|
58
|
+
* @type { string }
|
|
59
|
+
* @memberof ManagedTerminalInfo
|
|
60
|
+
*/
|
|
61
|
+
command: string;
|
|
62
|
+
/**
|
|
63
|
+
* @description Command arguments passed at launch
|
|
10
64
|
* @type { string[] }
|
|
11
|
-
* @memberof
|
|
12
|
-
|
|
13
|
-
args:
|
|
65
|
+
* @memberof ManagedTerminalInfo
|
|
66
|
+
*/
|
|
67
|
+
args: string[];
|
|
14
68
|
/**
|
|
15
|
-
* @description
|
|
69
|
+
* @description Working directory the terminal was launched in
|
|
70
|
+
* @type { string }
|
|
71
|
+
* @memberof ManagedTerminalInfo
|
|
72
|
+
*/
|
|
73
|
+
cwd: string;
|
|
74
|
+
/**
|
|
75
|
+
* @description OS process ID of the terminal process
|
|
16
76
|
* @type { number }
|
|
17
|
-
* @memberof
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
77
|
+
* @memberof ManagedTerminalInfo
|
|
78
|
+
*/
|
|
79
|
+
pid: number;
|
|
80
|
+
/**
|
|
81
|
+
* @description ISO 8601 timestamp when the terminal was created
|
|
82
|
+
* @type { string }
|
|
83
|
+
* @memberof ManagedTerminalInfo
|
|
84
|
+
*/
|
|
85
|
+
createdAt: string;
|
|
86
|
+
/**
|
|
87
|
+
* @description ISO 8601 timestamp when the process exited, or null if still running
|
|
88
|
+
* @type { string }
|
|
89
|
+
* @memberof ManagedTerminalInfo
|
|
90
|
+
*/
|
|
91
|
+
exitedAt: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* @description Current lifecycle status of the terminal
|
|
94
|
+
* @type { TerminalStatus }
|
|
95
|
+
* @memberof ManagedTerminalInfo
|
|
96
|
+
*/
|
|
97
|
+
status: TerminalStatus;
|
|
98
|
+
/**
|
|
99
|
+
* @description Process exit code (0 = success), or null if still running
|
|
100
|
+
* @type { number }
|
|
101
|
+
* @memberof ManagedTerminalInfo
|
|
102
|
+
*/
|
|
103
|
+
exitCode: number | null;
|
|
104
|
+
/**
|
|
105
|
+
* @description PID of the PTY holder process, or null if not using holder architecture
|
|
106
|
+
* @type { number }
|
|
107
|
+
* @memberof ManagedTerminalInfo
|
|
108
|
+
*/
|
|
109
|
+
holderPid: number | null;
|
|
110
|
+
/**
|
|
111
|
+
* @description Unix domain socket path for the holder process, or null if not applicable
|
|
112
|
+
* @type { string }
|
|
113
|
+
* @memberof ManagedTerminalInfo
|
|
114
|
+
*/
|
|
115
|
+
socketPath: string | null;
|
|
116
|
+
/**
|
|
117
|
+
* @description Whether the terminal is currently producing output (true) or idle (false)
|
|
118
|
+
* @type { boolean }
|
|
119
|
+
* @memberof ManagedTerminalInfo
|
|
120
|
+
*/
|
|
121
|
+
isActive: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* @description Current working directory detected via OSC 7, or null if not yet detected
|
|
124
|
+
* @type { string }
|
|
125
|
+
* @memberof ManagedTerminalInfo
|
|
126
|
+
*/
|
|
127
|
+
currentCwd: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export function decodeManagedTerminalInfo(rawInput: unknown): ManagedTerminalInfo | null {
|
|
131
|
+
if (isJSON(rawInput)) {
|
|
132
|
+
const decodedId = decodeString(rawInput['id']);
|
|
133
|
+
const decodedCommand = decodeString(rawInput['command']);
|
|
134
|
+
const decodedArgs = decodeArray(rawInput['args'], decodeString);
|
|
135
|
+
const decodedCwd = decodeString(rawInput['cwd']);
|
|
136
|
+
const decodedPid = decodeNumber(rawInput['pid']);
|
|
137
|
+
const decodedCreatedAt = decodeString(rawInput['createdAt']);
|
|
138
|
+
const decodedExitedAt = decodeString(rawInput['exitedAt']);
|
|
139
|
+
const decodedStatus = decodeTerminalStatus(rawInput['status']);
|
|
140
|
+
const decodedExitCode = decodeNumber(rawInput['exitCode']);
|
|
141
|
+
const decodedHolderPid = decodeNumber(rawInput['holderPid']);
|
|
142
|
+
const decodedSocketPath = decodeString(rawInput['socketPath']);
|
|
143
|
+
const decodedIsActive = decodeBoolean(rawInput['isActive']);
|
|
144
|
+
const decodedCurrentCwd = decodeString(rawInput['currentCwd']);
|
|
145
|
+
|
|
146
|
+
if (
|
|
147
|
+
decodedId === null ||
|
|
148
|
+
decodedCommand === null ||
|
|
149
|
+
decodedArgs === null ||
|
|
150
|
+
decodedCwd === null ||
|
|
151
|
+
decodedPid === null ||
|
|
152
|
+
decodedCreatedAt === null ||
|
|
153
|
+
decodedStatus === null ||
|
|
154
|
+
decodedIsActive === null ||
|
|
155
|
+
decodedCurrentCwd === null
|
|
156
|
+
) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
id: decodedId,
|
|
162
|
+
command: decodedCommand,
|
|
163
|
+
args: decodedArgs,
|
|
164
|
+
cwd: decodedCwd,
|
|
165
|
+
pid: decodedPid,
|
|
166
|
+
createdAt: decodedCreatedAt,
|
|
167
|
+
exitedAt: decodedExitedAt,
|
|
168
|
+
status: decodedStatus,
|
|
169
|
+
exitCode: decodedExitCode,
|
|
170
|
+
holderPid: decodedHolderPid,
|
|
171
|
+
socketPath: decodedSocketPath,
|
|
172
|
+
isActive: decodedIsActive,
|
|
173
|
+
currentCwd: decodedCurrentCwd,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @type { CreateTerminalRequest }
|
|
181
|
+
* @description Request body for creating a new managed terminal session
|
|
182
|
+
*/
|
|
183
|
+
export type CreateTerminalRequest = {
|
|
184
|
+
/**
|
|
21
185
|
* @description The command to execute (e.g. "zsh", "claude", "opencode")
|
|
22
186
|
* @type { string }
|
|
23
187
|
* @memberof CreateTerminalRequest
|
|
24
|
-
|
|
188
|
+
*/
|
|
25
189
|
command: string;
|
|
190
|
+
/**
|
|
191
|
+
* @description Optional command arguments
|
|
192
|
+
* @type { string[] }
|
|
193
|
+
* @memberof CreateTerminalRequest
|
|
194
|
+
*/
|
|
195
|
+
args: string[] | null;
|
|
26
196
|
/**
|
|
27
197
|
* @description Working directory for the new terminal
|
|
28
198
|
* @type { string }
|
|
29
199
|
* @memberof CreateTerminalRequest
|
|
30
|
-
|
|
200
|
+
*/
|
|
31
201
|
cwd: string;
|
|
32
|
-
|
|
202
|
+
/**
|
|
203
|
+
* @description Terminal width in columns (default 80)
|
|
204
|
+
* @type { number }
|
|
205
|
+
* @memberof CreateTerminalRequest
|
|
206
|
+
*/
|
|
207
|
+
cols: number | null;
|
|
208
|
+
/**
|
|
33
209
|
* @description Terminal height in rows (default 24)
|
|
34
210
|
* @type { number }
|
|
35
211
|
* @memberof CreateTerminalRequest
|
|
36
|
-
|
|
37
|
-
rows:
|
|
212
|
+
*/
|
|
213
|
+
rows: number | null;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export function decodeCreateTerminalRequest(rawInput: unknown): CreateTerminalRequest | null {
|
|
217
|
+
if (isJSON(rawInput)) {
|
|
218
|
+
const decodedCommand = decodeString(rawInput['command']);
|
|
219
|
+
const decodedArgs = decodeArray(rawInput['args'], decodeString);
|
|
220
|
+
const decodedCwd = decodeString(rawInput['cwd']);
|
|
221
|
+
const decodedCols = decodeNumber(rawInput['cols']);
|
|
222
|
+
const decodedRows = decodeNumber(rawInput['rows']);
|
|
223
|
+
|
|
224
|
+
if (decodedCommand === null || decodedCwd === null) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
command: decodedCommand,
|
|
230
|
+
args: decodedArgs,
|
|
231
|
+
cwd: decodedCwd,
|
|
232
|
+
cols: decodedCols,
|
|
233
|
+
rows: decodedRows,
|
|
234
|
+
};
|
|
38
235
|
}
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
39
238
|
|
|
40
239
|
/**
|
|
41
240
|
* @type { CreateTerminalResponse }
|
|
42
241
|
* @description Response after successfully creating a managed terminal session
|
|
43
242
|
*/
|
|
44
|
-
export
|
|
243
|
+
export type CreateTerminalResponse = {
|
|
45
244
|
/**
|
|
46
|
-
* @description
|
|
245
|
+
* @description Unique terminal identifier
|
|
47
246
|
* @type { string }
|
|
48
247
|
* @memberof CreateTerminalResponse
|
|
49
|
-
|
|
50
|
-
|
|
248
|
+
*/
|
|
249
|
+
id: string;
|
|
51
250
|
/**
|
|
52
|
-
* @description
|
|
251
|
+
* @description OS process ID of the spawned process
|
|
252
|
+
* @type { number }
|
|
253
|
+
* @memberof CreateTerminalResponse
|
|
254
|
+
*/
|
|
255
|
+
pid: number;
|
|
256
|
+
/**
|
|
257
|
+
* @description The command that was launched
|
|
53
258
|
* @type { string }
|
|
54
259
|
* @memberof CreateTerminalResponse
|
|
55
|
-
|
|
56
|
-
|
|
260
|
+
*/
|
|
261
|
+
command: string;
|
|
57
262
|
/**
|
|
58
263
|
* @description Working directory the terminal was launched in
|
|
59
264
|
* @type { string }
|
|
60
265
|
* @memberof CreateTerminalResponse
|
|
61
|
-
|
|
266
|
+
*/
|
|
62
267
|
cwd: string;
|
|
63
268
|
/**
|
|
64
|
-
* @description
|
|
269
|
+
* @description WebSocket path for raw terminal I/O (e.g. "/ws/terminal/term_a1b2c3")
|
|
65
270
|
* @type { string }
|
|
66
271
|
* @memberof CreateTerminalResponse
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @description OS process ID of the spawned process
|
|
71
|
-
* @type { number }
|
|
72
|
-
* @memberof CreateTerminalResponse
|
|
73
|
-
*/
|
|
74
|
-
pid: number;
|
|
272
|
+
*/
|
|
273
|
+
ws: string;
|
|
75
274
|
/**
|
|
76
275
|
* @description WebSocket path for structured session stream, or null if not an AI session
|
|
77
276
|
* @type { string }
|
|
78
277
|
* @memberof CreateTerminalResponse
|
|
79
|
-
|
|
80
|
-
sessionWs:
|
|
81
|
-
|
|
82
|
-
* @description
|
|
278
|
+
*/
|
|
279
|
+
sessionWs: string | null;
|
|
280
|
+
/**
|
|
281
|
+
* @description ISO 8601 timestamp when the terminal was created
|
|
83
282
|
* @type { string }
|
|
84
283
|
* @memberof CreateTerminalResponse
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
284
|
+
*/
|
|
285
|
+
createdAt: string;
|
|
286
|
+
};
|
|
88
287
|
|
|
89
|
-
export
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
288
|
+
export function decodeCreateTerminalResponse(rawInput: unknown): CreateTerminalResponse | null {
|
|
289
|
+
if (isJSON(rawInput)) {
|
|
290
|
+
const decodedId = decodeString(rawInput['id']);
|
|
291
|
+
const decodedPid = decodeNumber(rawInput['pid']);
|
|
292
|
+
const decodedCommand = decodeString(rawInput['command']);
|
|
293
|
+
const decodedCwd = decodeString(rawInput['cwd']);
|
|
294
|
+
const decodedWs = decodeString(rawInput['ws']);
|
|
295
|
+
const decodedSessionWs = decodeString(rawInput['sessionWs']);
|
|
296
|
+
const decodedCreatedAt = decodeString(rawInput['createdAt']);
|
|
97
297
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
* @memberof HolderClientMessage1
|
|
119
|
-
*/
|
|
120
|
-
pid: number;
|
|
121
|
-
/**
|
|
122
|
-
* @type { string }
|
|
123
|
-
* @memberof HolderClientMessage1
|
|
124
|
-
*/
|
|
125
|
-
type: string;
|
|
298
|
+
if (
|
|
299
|
+
decodedId === null ||
|
|
300
|
+
decodedPid === null ||
|
|
301
|
+
decodedCommand === null ||
|
|
302
|
+
decodedCwd === null ||
|
|
303
|
+
decodedWs === null ||
|
|
304
|
+
decodedCreatedAt === null
|
|
305
|
+
) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
id: decodedId,
|
|
311
|
+
pid: decodedPid,
|
|
312
|
+
command: decodedCommand,
|
|
313
|
+
cwd: decodedCwd,
|
|
314
|
+
ws: decodedWs,
|
|
315
|
+
sessionWs: decodedSessionWs,
|
|
316
|
+
createdAt: decodedCreatedAt,
|
|
317
|
+
};
|
|
126
318
|
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
127
321
|
|
|
128
322
|
/**
|
|
129
|
-
* @type {
|
|
130
|
-
* @description
|
|
323
|
+
* @type { TerminalListResponse }
|
|
324
|
+
* @description Response for listing all managed terminal sessions
|
|
131
325
|
*/
|
|
132
|
-
export
|
|
326
|
+
export type TerminalListResponse = {
|
|
133
327
|
/**
|
|
134
|
-
* @description
|
|
135
|
-
* @type {
|
|
136
|
-
* @memberof
|
|
137
|
-
|
|
138
|
-
|
|
328
|
+
* @description Array of managed terminal info objects
|
|
329
|
+
* @type { ManagedTerminalInfo[] }
|
|
330
|
+
* @memberof TerminalListResponse
|
|
331
|
+
*/
|
|
332
|
+
terminals: ManagedTerminalInfo[];
|
|
139
333
|
/**
|
|
140
|
-
* @
|
|
141
|
-
* @
|
|
142
|
-
|
|
143
|
-
|
|
334
|
+
* @description Total number of terminals in the list
|
|
335
|
+
* @type { number }
|
|
336
|
+
* @memberof TerminalListResponse
|
|
337
|
+
*/
|
|
338
|
+
count: number;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export function decodeTerminalListResponse(rawInput: unknown): TerminalListResponse | null {
|
|
342
|
+
if (isJSON(rawInput)) {
|
|
343
|
+
const decodedTerminals = decodeArray(rawInput['terminals'], decodeManagedTerminalInfo);
|
|
344
|
+
const decodedCount = decodeNumber(rawInput['count']);
|
|
345
|
+
|
|
346
|
+
if (decodedTerminals === null || decodedCount === null) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
terminals: decodedTerminals,
|
|
352
|
+
count: decodedCount,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
144
356
|
}
|
|
145
357
|
|
|
146
358
|
/**
|
|
147
|
-
* @type {
|
|
148
|
-
* @description
|
|
359
|
+
* @type { WsTicketResponse }
|
|
360
|
+
* @description Response containing a short-lived ticket for WebSocket authentication
|
|
149
361
|
*/
|
|
150
|
-
export
|
|
362
|
+
export type WsTicketResponse = {
|
|
151
363
|
/**
|
|
152
|
-
* @description
|
|
364
|
+
* @description Single-use random ticket string (expires in 30 seconds)
|
|
153
365
|
* @type { string }
|
|
154
|
-
* @memberof
|
|
155
|
-
|
|
156
|
-
|
|
366
|
+
* @memberof WsTicketResponse
|
|
367
|
+
*/
|
|
368
|
+
ticket: string;
|
|
157
369
|
/**
|
|
370
|
+
* @description ISO 8601 timestamp when the ticket expires
|
|
158
371
|
* @type { string }
|
|
159
|
-
* @memberof
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
export interface HolderClientMessage4 {
|
|
169
|
-
/**
|
|
170
|
-
* @description Process exit code
|
|
171
|
-
* @type { number }
|
|
172
|
-
* @memberof HolderClientMessage4
|
|
173
|
-
*/
|
|
174
|
-
code: number;
|
|
175
|
-
/**
|
|
176
|
-
* @description Signal that caused exit
|
|
177
|
-
* @type { string }
|
|
178
|
-
* @memberof HolderClientMessage4
|
|
179
|
-
*/
|
|
180
|
-
signal: null | string;
|
|
181
|
-
/**
|
|
182
|
-
* @type { string }
|
|
183
|
-
* @memberof HolderClientMessage4
|
|
184
|
-
*/
|
|
185
|
-
type: string;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* @type { HolderClientMessage5 }
|
|
190
|
-
* @description Terminal activity state change (active/idle)
|
|
191
|
-
*/
|
|
192
|
-
export interface HolderClientMessage5 {
|
|
193
|
-
/**
|
|
194
|
-
* @description Whether the terminal is currently producing output
|
|
195
|
-
* @type { boolean }
|
|
196
|
-
* @memberof HolderClientMessage5
|
|
197
|
-
*/
|
|
198
|
-
active: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* @type { string }
|
|
201
|
-
* @memberof HolderClientMessage5
|
|
202
|
-
*/
|
|
203
|
-
type: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @type { HolderClientMessage6 }
|
|
208
|
-
* @description Current working directory change detected via OSC 7
|
|
209
|
-
*/
|
|
210
|
-
export interface HolderClientMessage6 {
|
|
211
|
-
/**
|
|
212
|
-
* @description Absolute path of the new working directory
|
|
213
|
-
* @type { string }
|
|
214
|
-
* @memberof HolderClientMessage6
|
|
215
|
-
*/
|
|
216
|
-
path: string;
|
|
217
|
-
/**
|
|
218
|
-
* @type { string }
|
|
219
|
-
* @memberof HolderClientMessage6
|
|
220
|
-
*/
|
|
221
|
-
type: string;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export type HolderServerMessage =
|
|
225
|
-
| CHolderServerMessage1
|
|
226
|
-
| CHolderServerMessage2
|
|
227
|
-
| CHolderServerMessage3
|
|
228
|
-
;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* @type { HolderServerMessage1 }
|
|
232
|
-
* @description Write data to PTY stdin
|
|
233
|
-
*/
|
|
234
|
-
export interface HolderServerMessage1 {
|
|
235
|
-
/**
|
|
236
|
-
* @description Raw input data to write to PTY
|
|
237
|
-
* @type { string }
|
|
238
|
-
* @memberof HolderServerMessage1
|
|
239
|
-
*/
|
|
240
|
-
data: string;
|
|
241
|
-
/**
|
|
242
|
-
* @type { string }
|
|
243
|
-
* @memberof HolderServerMessage1
|
|
244
|
-
*/
|
|
245
|
-
type: string;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* @type { HolderServerMessage2 }
|
|
251
|
-
* @description Resize the PTY dimensions
|
|
252
|
-
*/
|
|
253
|
-
export interface HolderServerMessage2 {
|
|
254
|
-
/**
|
|
255
|
-
* @description New width in columns
|
|
256
|
-
* @type { number }
|
|
257
|
-
* @memberof HolderServerMessage2
|
|
258
|
-
*/
|
|
259
|
-
cols: number;
|
|
260
|
-
/**
|
|
261
|
-
* @description New height in rows
|
|
262
|
-
* @type { number }
|
|
263
|
-
* @memberof HolderServerMessage2
|
|
264
|
-
*/
|
|
265
|
-
rows: number;
|
|
266
|
-
/**
|
|
267
|
-
* @type { string }
|
|
268
|
-
* @memberof HolderServerMessage2
|
|
269
|
-
*/
|
|
270
|
-
type: string;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* @type { HolderServerMessage3 }
|
|
275
|
-
* @description Send a signal to the PTY process
|
|
276
|
-
*/
|
|
277
|
-
export interface HolderServerMessage3 {
|
|
278
|
-
/**
|
|
279
|
-
* @description Signal name to send (default SIGTERM)
|
|
280
|
-
* @type { string }
|
|
281
|
-
* @memberof HolderServerMessage3
|
|
282
|
-
*/
|
|
283
|
-
signal: null | string;
|
|
284
|
-
/**
|
|
285
|
-
* @type { string }
|
|
286
|
-
* @memberof HolderServerMessage3
|
|
287
|
-
*/
|
|
288
|
-
type: string;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* @type { ManagedTerminalInfo }
|
|
294
|
-
* @description Serializable info about a managed terminal session (excludes runtime handles like PTY, watchers, client sets)
|
|
295
|
-
*/
|
|
296
|
-
export interface ManagedTerminalInfo {
|
|
297
|
-
/**
|
|
298
|
-
* @description Command arguments passed at launch
|
|
299
|
-
* @type { string[] }
|
|
300
|
-
* @memberof ManagedTerminalInfo
|
|
301
|
-
*/
|
|
302
|
-
args: string[];
|
|
303
|
-
/**
|
|
304
|
-
* @description The command that was launched (e.g. "zsh", "claude", "opencode")
|
|
305
|
-
* @type { string }
|
|
306
|
-
* @memberof ManagedTerminalInfo
|
|
307
|
-
*/
|
|
308
|
-
command: string;
|
|
309
|
-
/**
|
|
310
|
-
* @description ISO 8601 timestamp when the terminal was created
|
|
311
|
-
* @type { string }
|
|
312
|
-
* @memberof ManagedTerminalInfo
|
|
313
|
-
*/
|
|
314
|
-
createdAt: string;
|
|
315
|
-
/**
|
|
316
|
-
* @description Current working directory detected via OSC 7, or null if not yet detected
|
|
317
|
-
* @type { string }
|
|
318
|
-
* @memberof ManagedTerminalInfo
|
|
319
|
-
*/
|
|
320
|
-
currentCwd: null | string;
|
|
321
|
-
/**
|
|
322
|
-
* @description Working directory the terminal was launched in
|
|
323
|
-
* @type { string }
|
|
324
|
-
* @memberof ManagedTerminalInfo
|
|
325
|
-
*/
|
|
326
|
-
cwd: string;
|
|
327
|
-
/**
|
|
328
|
-
* @description Process exit code (0 = success), or null if still running
|
|
329
|
-
* @type { number }
|
|
330
|
-
* @memberof ManagedTerminalInfo
|
|
331
|
-
*/
|
|
332
|
-
exitCode: null | number;
|
|
333
|
-
/**
|
|
334
|
-
* @description ISO 8601 timestamp when the process exited, or null if still running
|
|
335
|
-
* @type { string }
|
|
336
|
-
* @memberof ManagedTerminalInfo
|
|
337
|
-
*/
|
|
338
|
-
exitedAt: null | string;
|
|
339
|
-
/**
|
|
340
|
-
* @description PID of the PTY holder process, or null if not using holder architecture
|
|
341
|
-
* @type { number }
|
|
342
|
-
* @memberof ManagedTerminalInfo
|
|
343
|
-
*/
|
|
344
|
-
holderPid: null | number;
|
|
345
|
-
/**
|
|
346
|
-
* @description Unique terminal identifier (e.g. "term_a1b2c3")
|
|
347
|
-
* @type { string }
|
|
348
|
-
* @memberof ManagedTerminalInfo
|
|
349
|
-
*/
|
|
350
|
-
id: string;
|
|
351
|
-
/**
|
|
352
|
-
* @description Whether the terminal is currently producing output (true) or idle (false)
|
|
353
|
-
* @type { boolean }
|
|
354
|
-
* @memberof ManagedTerminalInfo
|
|
355
|
-
*/
|
|
356
|
-
isActive: boolean | null;
|
|
357
|
-
/**
|
|
358
|
-
* @description OS process ID of the terminal process
|
|
359
|
-
* @type { number }
|
|
360
|
-
* @memberof ManagedTerminalInfo
|
|
361
|
-
*/
|
|
362
|
-
pid: number;
|
|
363
|
-
/**
|
|
364
|
-
* @description Unix domain socket path for the holder process, or null if not applicable
|
|
365
|
-
* @type { string }
|
|
366
|
-
* @memberof ManagedTerminalInfo
|
|
367
|
-
*/
|
|
368
|
-
socketPath: null | string;
|
|
369
|
-
/**
|
|
370
|
-
* @description Current lifecycle status of the terminal
|
|
371
|
-
* @type { TerminalStatus }
|
|
372
|
-
* @memberof ManagedTerminalInfo
|
|
373
|
-
*/
|
|
374
|
-
status: TerminalStatus;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* @type { RoleEnum }
|
|
379
|
-
* @description Who sent the message
|
|
380
|
-
*/
|
|
381
|
-
export type RoleEnum =
|
|
382
|
-
| 'assistant'
|
|
383
|
-
| 'user'
|
|
384
|
-
;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* @type { TerminalListResponse }
|
|
389
|
-
* @description Response for listing all managed terminal sessions
|
|
390
|
-
*/
|
|
391
|
-
export interface TerminalListResponse {
|
|
392
|
-
/**
|
|
393
|
-
* @description Total number of terminals in the list
|
|
394
|
-
* @type { number }
|
|
395
|
-
* @memberof TerminalListResponse
|
|
396
|
-
*/
|
|
397
|
-
count: number;
|
|
398
|
-
/**
|
|
399
|
-
* @description Array of managed terminal info objects
|
|
400
|
-
* @type { ManagedTerminalInfo[] }
|
|
401
|
-
* @memberof TerminalListResponse
|
|
402
|
-
*/
|
|
403
|
-
terminals: ManagedTerminalInfo[];
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* @type { TerminalRecord }
|
|
408
|
-
* @description Persisted terminal metadata stored in SQLite for recovery across server restarts
|
|
409
|
-
*/
|
|
410
|
-
export interface TerminalRecord {
|
|
411
|
-
/**
|
|
412
|
-
* @description JSON-encoded array of command arguments
|
|
413
|
-
* @type { string }
|
|
414
|
-
* @memberof TerminalRecord
|
|
415
|
-
*/
|
|
416
|
-
args: string;
|
|
417
|
-
/**
|
|
418
|
-
* @description Terminal width in columns
|
|
419
|
-
* @type { number }
|
|
420
|
-
* @memberof TerminalRecord
|
|
421
|
-
*/
|
|
422
|
-
cols: number;
|
|
423
|
-
/**
|
|
424
|
-
* @description The command that was launched
|
|
425
|
-
* @type { string }
|
|
426
|
-
* @memberof TerminalRecord
|
|
427
|
-
*/
|
|
428
|
-
command: string;
|
|
429
|
-
/**
|
|
430
|
-
* @description ISO 8601 timestamp when the terminal was created
|
|
431
|
-
* @type { string }
|
|
432
|
-
* @memberof TerminalRecord
|
|
433
|
-
*/
|
|
434
|
-
createdAt: string;
|
|
435
|
-
/**
|
|
436
|
-
* @description Working directory the terminal was launched in
|
|
437
|
-
* @type { string }
|
|
438
|
-
* @memberof TerminalRecord
|
|
439
|
-
*/
|
|
440
|
-
cwd: string;
|
|
441
|
-
/**
|
|
442
|
-
* @description Process exit code
|
|
443
|
-
* @type { number }
|
|
444
|
-
* @memberof TerminalRecord
|
|
445
|
-
*/
|
|
446
|
-
exitCode: null | number;
|
|
447
|
-
/**
|
|
448
|
-
* @description ISO 8601 timestamp when the process exited
|
|
449
|
-
* @type { string }
|
|
450
|
-
* @memberof TerminalRecord
|
|
451
|
-
*/
|
|
452
|
-
exitedAt: null | string;
|
|
453
|
-
/**
|
|
454
|
-
* @description Holder process ID
|
|
455
|
-
* @type { number }
|
|
456
|
-
* @memberof TerminalRecord
|
|
457
|
-
*/
|
|
458
|
-
holderPid: null | number;
|
|
459
|
-
/**
|
|
460
|
-
* @description Unique terminal identifier
|
|
461
|
-
* @type { string }
|
|
462
|
-
* @memberof TerminalRecord
|
|
463
|
-
*/
|
|
464
|
-
id: string;
|
|
465
|
-
/**
|
|
466
|
-
* @description OpenCode SQLite session ID
|
|
467
|
-
* @type { string }
|
|
468
|
-
* @memberof TerminalRecord
|
|
469
|
-
*/
|
|
470
|
-
opencodeSessionId: null | string;
|
|
471
|
-
/**
|
|
472
|
-
* @description PTY child process ID
|
|
473
|
-
* @type { number }
|
|
474
|
-
* @memberof TerminalRecord
|
|
475
|
-
*/
|
|
476
|
-
pid: null | number;
|
|
477
|
-
/**
|
|
478
|
-
* @description Terminal height in rows
|
|
479
|
-
* @type { number }
|
|
480
|
-
* @memberof TerminalRecord
|
|
481
|
-
*/
|
|
482
|
-
rows: number;
|
|
483
|
-
/**
|
|
484
|
-
* @description Claude Code JSONL session file path
|
|
485
|
-
* @type { string }
|
|
486
|
-
* @memberof TerminalRecord
|
|
487
|
-
*/
|
|
488
|
-
sessionFile: null | string;
|
|
489
|
-
/**
|
|
490
|
-
* @description Unix domain socket path for holder communication
|
|
491
|
-
* @type { string }
|
|
492
|
-
* @memberof TerminalRecord
|
|
493
|
-
*/
|
|
494
|
-
socketPath: null | string;
|
|
495
|
-
/**
|
|
496
|
-
* @description Terminal lifecycle status
|
|
497
|
-
* @type { TerminalStatus }
|
|
498
|
-
* @memberof TerminalRecord
|
|
499
|
-
*/
|
|
500
|
-
status: TerminalStatus;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* @type { TerminalStatus }
|
|
506
|
-
* @description Lifecycle status of a terminal session
|
|
507
|
-
*/
|
|
508
|
-
export type TerminalStatus =
|
|
509
|
-
| 'exited'
|
|
510
|
-
| 'orphaned'
|
|
511
|
-
| 'running'
|
|
512
|
-
;
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* @type { ToolExecutionStatus }
|
|
516
|
-
* @description Current execution status of a tool invocation
|
|
517
|
-
*/
|
|
518
|
-
export type ToolExecutionStatus =
|
|
519
|
-
| 'done'
|
|
520
|
-
| 'error'
|
|
521
|
-
| 'running'
|
|
522
|
-
;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* @type { ToolResultStatus }
|
|
527
|
-
* @description Whether a tool completed successfully or with an error
|
|
528
|
-
*/
|
|
529
|
-
export type ToolResultStatus =
|
|
530
|
-
| 'done'
|
|
531
|
-
| 'error'
|
|
532
|
-
;
|
|
533
|
-
|
|
534
|
-
export type WsEvent =
|
|
535
|
-
| CWsEvent1
|
|
536
|
-
| CWsEvent2
|
|
537
|
-
| CWsEvent3
|
|
538
|
-
| CWsEvent4
|
|
539
|
-
| CWsEvent5
|
|
540
|
-
;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* @type { WsEvent1 }
|
|
545
|
-
* @description A new AI session has started
|
|
546
|
-
*/
|
|
547
|
-
export interface WsEvent1 {
|
|
548
|
-
/**
|
|
549
|
-
* @description Project name or path
|
|
550
|
-
* @type { string }
|
|
551
|
-
* @memberof WsEvent1
|
|
552
|
-
*/
|
|
553
|
-
project: string;
|
|
554
|
-
/**
|
|
555
|
-
* @description Unique session identifier
|
|
556
|
-
* @type { string }
|
|
557
|
-
* @memberof WsEvent1
|
|
558
|
-
*/
|
|
559
|
-
sessionId: string;
|
|
560
|
-
/**
|
|
561
|
-
* @description Source tool that started the session (e.g. "claude-code", "opencode")
|
|
562
|
-
* @type { string }
|
|
563
|
-
* @memberof WsEvent1
|
|
564
|
-
*/
|
|
565
|
-
source: string;
|
|
566
|
-
/**
|
|
567
|
-
* @type { string }
|
|
568
|
-
* @memberof WsEvent1
|
|
569
|
-
*/
|
|
570
|
-
type: string;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* @type { WsEvent2 }
|
|
575
|
-
* @description An AI session has ended
|
|
576
|
-
*/
|
|
577
|
-
export interface WsEvent2 {
|
|
578
|
-
/**
|
|
579
|
-
* @description Session identifier that ended
|
|
580
|
-
* @type { string }
|
|
581
|
-
* @memberof WsEvent2
|
|
582
|
-
*/
|
|
583
|
-
sessionId: string;
|
|
584
|
-
/**
|
|
585
|
-
* @description Optional summary of what happened in the session
|
|
586
|
-
* @type { string }
|
|
587
|
-
* @memberof WsEvent2
|
|
588
|
-
*/
|
|
589
|
-
summary: null | string;
|
|
590
|
-
/**
|
|
591
|
-
* @type { string }
|
|
592
|
-
* @memberof WsEvent2
|
|
593
|
-
*/
|
|
594
|
-
type: string;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* @type { WsEvent3 }
|
|
602
|
-
* @description A permission request is awaiting approval
|
|
603
|
-
*/
|
|
604
|
-
export interface WsEvent3 {
|
|
605
|
-
/**
|
|
606
|
-
* @description Tool input that requires approval
|
|
607
|
-
* @type { WsEvent3Input }
|
|
608
|
-
* @memberof WsEvent3
|
|
609
|
-
*/
|
|
610
|
-
input: WsEvent3Input;
|
|
611
|
-
/**
|
|
612
|
-
* @description Unique request identifier for the permission flow
|
|
613
|
-
* @type { string }
|
|
614
|
-
* @memberof WsEvent3
|
|
615
|
-
*/
|
|
616
|
-
requestId: string;
|
|
617
|
-
/**
|
|
618
|
-
* @description Tool requesting permission (e.g. "Bash", "Edit")
|
|
619
|
-
* @type { string }
|
|
620
|
-
* @memberof WsEvent3
|
|
621
|
-
*/
|
|
622
|
-
tool: string;
|
|
623
|
-
/**
|
|
624
|
-
* @type { string }
|
|
625
|
-
* @memberof WsEvent3
|
|
626
|
-
*/
|
|
627
|
-
type: string;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* @type { WsEvent3Input }
|
|
632
|
-
* @description Tool input that requires approval
|
|
633
|
-
*/
|
|
634
|
-
export type WsEvent3Input = Record<string, unknown>;
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* @type { WsEvent4 }
|
|
640
|
-
* @description A new managed terminal has been created
|
|
641
|
-
*/
|
|
642
|
-
export interface WsEvent4 {
|
|
643
|
-
/**
|
|
644
|
-
* @description Command that was launched
|
|
645
|
-
* @type { string }
|
|
646
|
-
* @memberof WsEvent4
|
|
647
|
-
*/
|
|
648
|
-
command: string;
|
|
649
|
-
/**
|
|
650
|
-
* @description Unique terminal identifier
|
|
651
|
-
* @type { string }
|
|
652
|
-
* @memberof WsEvent4
|
|
653
|
-
*/
|
|
654
|
-
terminalId: string;
|
|
655
|
-
/**
|
|
656
|
-
* @type { string }
|
|
657
|
-
* @memberof WsEvent4
|
|
658
|
-
*/
|
|
659
|
-
type: string;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* @type { WsEvent5 }
|
|
664
|
-
* @description A managed terminal process has exited
|
|
665
|
-
*/
|
|
666
|
-
export interface WsEvent5 {
|
|
667
|
-
/**
|
|
668
|
-
* @description Process exit code
|
|
669
|
-
* @type { number }
|
|
670
|
-
* @memberof WsEvent5
|
|
671
|
-
*/
|
|
672
|
-
code: number;
|
|
673
|
-
/**
|
|
674
|
-
* @description Terminal identifier that exited
|
|
675
|
-
* @type { string }
|
|
676
|
-
* @memberof WsEvent5
|
|
677
|
-
*/
|
|
678
|
-
terminalId: string;
|
|
679
|
-
/**
|
|
680
|
-
* @type { string }
|
|
681
|
-
* @memberof WsEvent5
|
|
682
|
-
*/
|
|
683
|
-
type: string;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
export type WsSessionMessage =
|
|
689
|
-
| CWsSessionMessage1
|
|
690
|
-
| CWsSessionMessage2
|
|
691
|
-
| CWsSessionMessage3
|
|
692
|
-
;
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* @type { WsSessionMessage1 }
|
|
696
|
-
* @description Subscribe to a live AI session stream
|
|
697
|
-
*/
|
|
698
|
-
export interface WsSessionMessage1 {
|
|
699
|
-
/**
|
|
700
|
-
* @description Session ID to subscribe to
|
|
701
|
-
* @type { string }
|
|
702
|
-
* @memberof WsSessionMessage1
|
|
703
|
-
*/
|
|
704
|
-
sessionId: string;
|
|
705
|
-
/**
|
|
706
|
-
* @type { string }
|
|
707
|
-
* @memberof WsSessionMessage1
|
|
708
|
-
*/
|
|
709
|
-
type: string;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* @type { WsSessionMessage2 }
|
|
716
|
-
* @description Send text input to the AI session (writes to PTY stdin with newline)
|
|
717
|
-
*/
|
|
718
|
-
export interface WsSessionMessage2 {
|
|
719
|
-
/**
|
|
720
|
-
* @description Text to send to the AI session
|
|
721
|
-
* @type { string }
|
|
722
|
-
* @memberof WsSessionMessage2
|
|
723
|
-
*/
|
|
724
|
-
text: string;
|
|
725
|
-
/**
|
|
726
|
-
* @type { string }
|
|
727
|
-
* @memberof WsSessionMessage2
|
|
728
|
-
*/
|
|
729
|
-
type: string;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* @type { WsSessionMessage3 }
|
|
734
|
-
* @description Cancel the current AI operation (sends SIGINT to PTY)
|
|
735
|
-
*/
|
|
736
|
-
export interface WsSessionMessage3 {
|
|
737
|
-
/**
|
|
738
|
-
* @type { string }
|
|
739
|
-
* @memberof WsSessionMessage3
|
|
740
|
-
*/
|
|
741
|
-
type: string;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
export type WsSessionOutput =
|
|
747
|
-
| CWsSessionOutput1
|
|
748
|
-
| CWsSessionOutput2
|
|
749
|
-
| CWsSessionOutput3
|
|
750
|
-
| CWsSessionOutput4
|
|
751
|
-
| CWsSessionOutput5
|
|
752
|
-
| CWsSessionOutput6
|
|
753
|
-
;
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* @type { WsSessionOutput1 }
|
|
757
|
-
* @description Full conversation history sent on connect
|
|
758
|
-
*/
|
|
759
|
-
export interface WsSessionOutput1 {
|
|
760
|
-
/**
|
|
761
|
-
* @description All session messages from the beginning up to the current point
|
|
762
|
-
* @type { messagesItem[] }
|
|
763
|
-
* @memberof WsSessionOutput1
|
|
764
|
-
*/
|
|
765
|
-
messages: messagesItem[];
|
|
766
|
-
/**
|
|
767
|
-
* @type { string }
|
|
768
|
-
* @memberof WsSessionOutput1
|
|
769
|
-
*/
|
|
770
|
-
type: string;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* @type { WsSessionOutput2 }
|
|
777
|
-
* @description A new conversation message (user or assistant)
|
|
778
|
-
*/
|
|
779
|
-
export interface WsSessionOutput2 {
|
|
780
|
-
/**
|
|
781
|
-
* @description Message content blocks
|
|
782
|
-
* @type { contentItem[] }
|
|
783
|
-
* @memberof WsSessionOutput2
|
|
784
|
-
*/
|
|
785
|
-
content: contentItem[];
|
|
786
|
-
/**
|
|
787
|
-
* @description Who sent the message
|
|
788
|
-
* @type { RoleEnum }
|
|
789
|
-
* @memberof WsSessionOutput2
|
|
790
|
-
*/
|
|
791
|
-
role: RoleEnum;
|
|
792
|
-
/**
|
|
793
|
-
* @description ISO 8601 timestamp of the message
|
|
794
|
-
* @type { string }
|
|
795
|
-
* @memberof WsSessionOutput2
|
|
796
|
-
*/
|
|
797
|
-
timestamp: string;
|
|
798
|
-
/**
|
|
799
|
-
* @type { string }
|
|
800
|
-
* @memberof WsSessionOutput2
|
|
801
|
-
*/
|
|
802
|
-
type: string;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
/**
|
|
806
|
-
* @type { WsSessionOutput3 }
|
|
807
|
-
* @description A tool invocation by the AI assistant
|
|
808
|
-
*/
|
|
809
|
-
export interface WsSessionOutput3 {
|
|
810
|
-
/**
|
|
811
|
-
* @description Tool input parameters
|
|
812
|
-
* @type { WsSessionOutput3Input }
|
|
813
|
-
* @memberof WsSessionOutput3
|
|
814
|
-
*/
|
|
815
|
-
input: WsSessionOutput3Input;
|
|
816
|
-
/**
|
|
817
|
-
* @description Tool name (e.g. "Edit", "Bash", "Read")
|
|
818
|
-
* @type { string }
|
|
819
|
-
* @memberof WsSessionOutput3
|
|
820
|
-
*/
|
|
821
|
-
name: string;
|
|
822
|
-
/**
|
|
823
|
-
* @description Current execution status of the tool
|
|
824
|
-
* @type { ToolExecutionStatus }
|
|
825
|
-
* @memberof WsSessionOutput3
|
|
826
|
-
*/
|
|
827
|
-
status: ToolExecutionStatus;
|
|
828
|
-
/**
|
|
829
|
-
* @type { string }
|
|
830
|
-
* @memberof WsSessionOutput3
|
|
831
|
-
*/
|
|
832
|
-
type: string;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
/**
|
|
837
|
-
* @type { WsSessionOutput3Input }
|
|
838
|
-
* @description Tool input parameters
|
|
839
|
-
*/
|
|
840
|
-
export type WsSessionOutput3Input = Record<string, unknown>;
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* @type { WsSessionOutput4 }
|
|
844
|
-
* @description Result from a completed tool invocation
|
|
845
|
-
*/
|
|
846
|
-
export interface WsSessionOutput4 {
|
|
847
|
-
/**
|
|
848
|
-
* @description Tool use ID this result corresponds to
|
|
849
|
-
* @type { string }
|
|
850
|
-
* @memberof WsSessionOutput4
|
|
851
|
-
*/
|
|
852
|
-
id: string;
|
|
853
|
-
/**
|
|
854
|
-
* @description Tool output text
|
|
855
|
-
* @type { string }
|
|
856
|
-
* @memberof WsSessionOutput4
|
|
857
|
-
*/
|
|
858
|
-
output: string;
|
|
859
|
-
/**
|
|
860
|
-
* @description Whether the tool completed successfully
|
|
861
|
-
* @type { ToolResultStatus }
|
|
862
|
-
* @memberof WsSessionOutput4
|
|
863
|
-
*/
|
|
864
|
-
status: ToolResultStatus;
|
|
865
|
-
/**
|
|
866
|
-
* @type { string }
|
|
867
|
-
* @memberof WsSessionOutput4
|
|
868
|
-
*/
|
|
869
|
-
type: string;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* @type { WsSessionOutput5 }
|
|
877
|
-
* @description AI thinking/reasoning block (extended thinking)
|
|
878
|
-
*/
|
|
879
|
-
export interface WsSessionOutput5 {
|
|
880
|
-
/**
|
|
881
|
-
* @description Thinking content text
|
|
882
|
-
* @type { string }
|
|
883
|
-
* @memberof WsSessionOutput5
|
|
884
|
-
*/
|
|
885
|
-
text: string;
|
|
886
|
-
/**
|
|
887
|
-
* @type { string }
|
|
888
|
-
* @memberof WsSessionOutput5
|
|
889
|
-
*/
|
|
890
|
-
type: string;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* @type { WsSessionOutput6 }
|
|
895
|
-
* @description Session has ended (process exited or session file closed)
|
|
896
|
-
*/
|
|
897
|
-
export interface WsSessionOutput6 {
|
|
898
|
-
/**
|
|
899
|
-
* @type { string }
|
|
900
|
-
* @memberof WsSessionOutput6
|
|
901
|
-
*/
|
|
902
|
-
type: string;
|
|
903
|
-
}
|
|
372
|
+
* @memberof WsTicketResponse
|
|
373
|
+
*/
|
|
374
|
+
expiresAt: string;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export function decodeWsTicketResponse(rawInput: unknown): WsTicketResponse | null {
|
|
378
|
+
if (isJSON(rawInput)) {
|
|
379
|
+
const decodedTicket = decodeString(rawInput['ticket']);
|
|
380
|
+
const decodedExpiresAt = decodeString(rawInput['expiresAt']);
|
|
904
381
|
|
|
382
|
+
if (decodedTicket === null || decodedExpiresAt === null) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
905
385
|
|
|
386
|
+
return {
|
|
387
|
+
ticket: decodedTicket,
|
|
388
|
+
expiresAt: decodedExpiresAt,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
906
393
|
|
|
907
394
|
/**
|
|
908
395
|
* @type { WsStatusResponse }
|
|
909
396
|
* @description Response indicating how many WebSocket clients are currently connected
|
|
910
397
|
*/
|
|
911
|
-
export
|
|
398
|
+
export type WsStatusResponse = {
|
|
912
399
|
/**
|
|
913
400
|
* @description Number of active WebSocket connections across all channels
|
|
914
401
|
* @type { number }
|
|
915
402
|
* @memberof WsStatusResponse
|
|
916
|
-
|
|
403
|
+
*/
|
|
917
404
|
connectedClients: number;
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
export type WsTerminalMessage =
|
|
921
|
-
| CWsTerminalMessage1
|
|
922
|
-
| CWsTerminalMessage2
|
|
923
|
-
| CWsTerminalMessage3
|
|
924
|
-
;
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* @type { WsTerminalMessage1 }
|
|
930
|
-
* @description Send keyboard input to the terminal PTY
|
|
931
|
-
*/
|
|
932
|
-
export interface WsTerminalMessage1 {
|
|
933
|
-
/**
|
|
934
|
-
* @description Raw terminal input data (keystrokes, pasted text)
|
|
935
|
-
* @type { string }
|
|
936
|
-
* @memberof WsTerminalMessage1
|
|
937
|
-
*/
|
|
938
|
-
data: string;
|
|
939
|
-
/**
|
|
940
|
-
* @type { string }
|
|
941
|
-
* @memberof WsTerminalMessage1
|
|
942
|
-
*/
|
|
943
|
-
type: string;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* @type { WsTerminalMessage2 }
|
|
948
|
-
* @description Resize the terminal PTY dimensions
|
|
949
|
-
*/
|
|
950
|
-
export interface WsTerminalMessage2 {
|
|
951
|
-
/**
|
|
952
|
-
* @description New terminal width in columns
|
|
953
|
-
* @type { number }
|
|
954
|
-
* @memberof WsTerminalMessage2
|
|
955
|
-
*/
|
|
956
|
-
cols: number;
|
|
957
|
-
/**
|
|
958
|
-
* @description New terminal height in rows
|
|
959
|
-
* @type { number }
|
|
960
|
-
* @memberof WsTerminalMessage2
|
|
961
|
-
*/
|
|
962
|
-
rows: number;
|
|
963
|
-
/**
|
|
964
|
-
* @type { string }
|
|
965
|
-
* @memberof WsTerminalMessage2
|
|
966
|
-
*/
|
|
967
|
-
type: string;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* @type { WsTerminalMessage3 }
|
|
974
|
-
* @description Send a signal to the terminal process
|
|
975
|
-
*/
|
|
976
|
-
export interface WsTerminalMessage3 {
|
|
977
|
-
/**
|
|
978
|
-
* @description Signal name to send (e.g. "SIGINT", "SIGTERM", "SIGTSTP")
|
|
979
|
-
* @type { string }
|
|
980
|
-
* @memberof WsTerminalMessage3
|
|
981
|
-
*/
|
|
982
|
-
signal: string;
|
|
983
|
-
/**
|
|
984
|
-
* @type { string }
|
|
985
|
-
* @memberof WsTerminalMessage3
|
|
986
|
-
*/
|
|
987
|
-
type: string;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
export type WsTerminalOutput =
|
|
991
|
-
| CWsTerminalOutput1
|
|
992
|
-
| CWsTerminalOutput2
|
|
993
|
-
| CWsTerminalOutput3
|
|
994
|
-
| CWsTerminalOutput4
|
|
995
|
-
;
|
|
996
|
-
|
|
405
|
+
};
|
|
997
406
|
|
|
407
|
+
export function decodeWsStatusResponse(rawInput: unknown): WsStatusResponse | null {
|
|
408
|
+
if (isJSON(rawInput)) {
|
|
409
|
+
const decodedConnectedClients = decodeNumber(rawInput['connectedClients']);
|
|
998
410
|
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
*/
|
|
1003
|
-
export interface WsTerminalOutput1 {
|
|
1004
|
-
/**
|
|
1005
|
-
* @description Raw terminal output data
|
|
1006
|
-
* @type { string }
|
|
1007
|
-
* @memberof WsTerminalOutput1
|
|
1008
|
-
*/
|
|
1009
|
-
data: string;
|
|
1010
|
-
/**
|
|
1011
|
-
* @type { string }
|
|
1012
|
-
* @memberof WsTerminalOutput1
|
|
1013
|
-
*/
|
|
1014
|
-
type: string;
|
|
1015
|
-
}
|
|
411
|
+
if (decodedConnectedClients === null) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
1016
414
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
*/
|
|
1021
|
-
export interface WsTerminalOutput2 {
|
|
1022
|
-
/**
|
|
1023
|
-
* @description Process exit code
|
|
1024
|
-
* @type { number }
|
|
1025
|
-
* @memberof WsTerminalOutput2
|
|
1026
|
-
*/
|
|
1027
|
-
code: number;
|
|
1028
|
-
/**
|
|
1029
|
-
* @description Signal that caused the exit, or null if exited normally
|
|
1030
|
-
* @type { string }
|
|
1031
|
-
* @memberof WsTerminalOutput2
|
|
1032
|
-
*/
|
|
1033
|
-
signal: null | string;
|
|
1034
|
-
/**
|
|
1035
|
-
* @type { string }
|
|
1036
|
-
* @memberof WsTerminalOutput2
|
|
1037
|
-
*/
|
|
1038
|
-
type: string;
|
|
415
|
+
return {
|
|
416
|
+
connectedClients: decodedConnectedClients,
|
|
417
|
+
};
|
|
1039
418
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
/**
|
|
1044
|
-
* @type { WsTerminalOutput3 }
|
|
1045
|
-
* @description Scrollback chunk sent on reconnection
|
|
1046
|
-
*/
|
|
1047
|
-
export interface WsTerminalOutput3 {
|
|
1048
|
-
/**
|
|
1049
|
-
* @description 1-based chunk index
|
|
1050
|
-
* @type { number }
|
|
1051
|
-
* @memberof WsTerminalOutput3
|
|
1052
|
-
*/
|
|
1053
|
-
chunk: number;
|
|
1054
|
-
/**
|
|
1055
|
-
* @description Scrollback content for this chunk (max 50KB)
|
|
1056
|
-
* @type { string }
|
|
1057
|
-
* @memberof WsTerminalOutput3
|
|
1058
|
-
*/
|
|
1059
|
-
data: string;
|
|
1060
|
-
/**
|
|
1061
|
-
* @description Total number of scrollback chunks
|
|
1062
|
-
* @type { number }
|
|
1063
|
-
* @memberof WsTerminalOutput3
|
|
1064
|
-
*/
|
|
1065
|
-
total: number;
|
|
1066
|
-
/**
|
|
1067
|
-
* @type { string }
|
|
1068
|
-
* @memberof WsTerminalOutput3
|
|
1069
|
-
*/
|
|
1070
|
-
type: string;
|
|
419
|
+
return null;
|
|
1071
420
|
}
|
|
1072
421
|
|
|
1073
422
|
/**
|
|
1074
|
-
* @type {
|
|
1075
|
-
* @description
|
|
423
|
+
* @type { WsTerminalInputMessage }
|
|
424
|
+
* @description Send keyboard input to the terminal PTY
|
|
1076
425
|
*/
|
|
1077
|
-
export
|
|
1078
|
-
/**
|
|
1079
|
-
* @description Human-readable error message
|
|
1080
|
-
* @type { string }
|
|
1081
|
-
* @memberof WsTerminalOutput4
|
|
1082
|
-
*/
|
|
1083
|
-
message: string;
|
|
426
|
+
export type WsTerminalInputMessage = {
|
|
1084
427
|
/**
|
|
1085
428
|
* @type { string }
|
|
1086
|
-
* @memberof
|
|
1087
|
-
|
|
429
|
+
* @memberof WsTerminalInputMessage
|
|
430
|
+
*/
|
|
1088
431
|
type: string;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
/**
|
|
1094
|
-
* @type { WsTicketResponse }
|
|
1095
|
-
* @description Response containing a short-lived ticket for WebSocket authentication
|
|
1096
|
-
*/
|
|
1097
|
-
export interface WsTicketResponse {
|
|
1098
|
-
/**
|
|
1099
|
-
* @description ISO 8601 timestamp when the ticket expires
|
|
1100
|
-
* @type { string }
|
|
1101
|
-
* @memberof WsTicketResponse
|
|
1102
|
-
*/
|
|
1103
|
-
expiresAt: string;
|
|
1104
432
|
/**
|
|
1105
|
-
* @description
|
|
433
|
+
* @description Raw terminal input data (keystrokes, pasted text)
|
|
1106
434
|
* @type { string }
|
|
1107
|
-
* @memberof
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
export class CHolderClientMessageHolderClientMessage1 {
|
|
1113
|
-
data: HolderClientMessage1;
|
|
1114
|
-
constructor(data: HolderClientMessage1) {
|
|
1115
|
-
this.data = data;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
export class CHolderClientMessageHolderClientMessage2 {
|
|
1122
|
-
data: HolderClientMessage2;
|
|
1123
|
-
constructor(data: HolderClientMessage2) {
|
|
1124
|
-
this.data = data;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
export class CHolderClientMessageHolderClientMessage3 {
|
|
1129
|
-
data: HolderClientMessage3;
|
|
1130
|
-
constructor(data: HolderClientMessage3) {
|
|
1131
|
-
this.data = data;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
export class CHolderClientMessageHolderClientMessage4 {
|
|
1137
|
-
data: HolderClientMessage4;
|
|
1138
|
-
constructor(data: HolderClientMessage4) {
|
|
1139
|
-
this.data = data;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
export class CHolderClientMessageHolderClientMessage5 {
|
|
1144
|
-
data: HolderClientMessage5;
|
|
1145
|
-
constructor(data: HolderClientMessage5) {
|
|
1146
|
-
this.data = data;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
export class CHolderClientMessageHolderClientMessage6 {
|
|
1154
|
-
data: HolderClientMessage6;
|
|
1155
|
-
constructor(data: HolderClientMessage6) {
|
|
1156
|
-
this.data = data;
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
export class CHolderServerMessageHolderServerMessage1 {
|
|
1161
|
-
data: HolderServerMessage1;
|
|
1162
|
-
constructor(data: HolderServerMessage1) {
|
|
1163
|
-
this.data = data;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
export class CHolderServerMessageHolderServerMessage2 {
|
|
1170
|
-
data: HolderServerMessage2;
|
|
1171
|
-
constructor(data: HolderServerMessage2) {
|
|
1172
|
-
this.data = data;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
export class CHolderServerMessageHolderServerMessage3 {
|
|
1177
|
-
data: HolderServerMessage3;
|
|
1178
|
-
constructor(data: HolderServerMessage3) {
|
|
1179
|
-
this.data = data;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
export class CWsEventWsEvent1 {
|
|
1186
|
-
data: WsEvent1;
|
|
1187
|
-
constructor(data: WsEvent1) {
|
|
1188
|
-
this.data = data;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
export class CWsEventWsEvent2 {
|
|
1193
|
-
data: WsEvent2;
|
|
1194
|
-
constructor(data: WsEvent2) {
|
|
1195
|
-
this.data = data;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
export class CWsEventWsEvent3 {
|
|
1202
|
-
data: WsEvent3;
|
|
1203
|
-
constructor(data: WsEvent3) {
|
|
1204
|
-
this.data = data;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
export class CWsEventWsEvent4 {
|
|
1209
|
-
data: WsEvent4;
|
|
1210
|
-
constructor(data: WsEvent4) {
|
|
1211
|
-
this.data = data;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
export class CWsEventWsEvent5 {
|
|
1218
|
-
data: WsEvent5;
|
|
1219
|
-
constructor(data: WsEvent5) {
|
|
1220
|
-
this.data = data;
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
export class CWsSessionMessageWsSessionMessage1 {
|
|
1225
|
-
data: WsSessionMessage1;
|
|
1226
|
-
constructor(data: WsSessionMessage1) {
|
|
1227
|
-
this.data = data;
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
export class CWsSessionMessageWsSessionMessage2 {
|
|
1234
|
-
data: WsSessionMessage2;
|
|
1235
|
-
constructor(data: WsSessionMessage2) {
|
|
1236
|
-
this.data = data;
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
export class CWsSessionMessageWsSessionMessage3 {
|
|
1241
|
-
data: WsSessionMessage3;
|
|
1242
|
-
constructor(data: WsSessionMessage3) {
|
|
1243
|
-
this.data = data;
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
export class CWsSessionOutputWsSessionOutput1 {
|
|
1249
|
-
data: WsSessionOutput1;
|
|
1250
|
-
constructor(data: WsSessionOutput1) {
|
|
1251
|
-
this.data = data;
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
export class CWsSessionOutputWsSessionOutput2 {
|
|
1256
|
-
data: WsSessionOutput2;
|
|
1257
|
-
constructor(data: WsSessionOutput2) {
|
|
1258
|
-
this.data = data;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
export class CWsSessionOutputWsSessionOutput3 {
|
|
1266
|
-
data: WsSessionOutput3;
|
|
1267
|
-
constructor(data: WsSessionOutput3) {
|
|
1268
|
-
this.data = data;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
export class CWsSessionOutputWsSessionOutput4 {
|
|
1273
|
-
data: WsSessionOutput4;
|
|
1274
|
-
constructor(data: WsSessionOutput4) {
|
|
1275
|
-
this.data = data;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
export class CWsSessionOutputWsSessionOutput5 {
|
|
1282
|
-
data: WsSessionOutput5;
|
|
1283
|
-
constructor(data: WsSessionOutput5) {
|
|
1284
|
-
this.data = data;
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
export class CWsSessionOutputWsSessionOutput6 {
|
|
1289
|
-
data: WsSessionOutput6;
|
|
1290
|
-
constructor(data: WsSessionOutput6) {
|
|
1291
|
-
this.data = data;
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
435
|
+
* @memberof WsTerminalInputMessage
|
|
436
|
+
*/
|
|
437
|
+
data: string;
|
|
438
|
+
};
|
|
1296
439
|
|
|
1297
|
-
export
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
440
|
+
export function decodeWsTerminalInputMessage(rawInput: unknown): WsTerminalInputMessage | null {
|
|
441
|
+
if (isJSON(rawInput)) {
|
|
442
|
+
const decodedType = decodeString(rawInput['type']);
|
|
443
|
+
const decodedData = decodeString(rawInput['data']);
|
|
1303
444
|
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
this.data = data;
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
445
|
+
if (decodedType === null || decodedData === null) {
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
1310
448
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
449
|
+
return {
|
|
450
|
+
type: decodedType,
|
|
451
|
+
data: decodedData,
|
|
452
|
+
};
|
|
1315
453
|
}
|
|
454
|
+
return null;
|
|
1316
455
|
}
|
|
1317
456
|
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
457
|
+
/**
|
|
458
|
+
* @type { WsTerminalResizeMessage }
|
|
459
|
+
* @description Resize the terminal PTY dimensions
|
|
460
|
+
*/
|
|
461
|
+
export type WsTerminalResizeMessage = {
|
|
462
|
+
/**
|
|
463
|
+
* @type { string }
|
|
464
|
+
* @memberof WsTerminalResizeMessage
|
|
465
|
+
*/
|
|
466
|
+
type: string;
|
|
467
|
+
/**
|
|
468
|
+
* @description New terminal width in columns (1-500)
|
|
469
|
+
* @type { number }
|
|
470
|
+
* @memberof WsTerminalResizeMessage
|
|
471
|
+
*/
|
|
472
|
+
cols: number;
|
|
473
|
+
/**
|
|
474
|
+
* @description New terminal height in rows (1-200)
|
|
475
|
+
* @type { number }
|
|
476
|
+
* @memberof WsTerminalResizeMessage
|
|
477
|
+
*/
|
|
478
|
+
rows: number;
|
|
479
|
+
};
|
|
1324
480
|
|
|
1325
|
-
export
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
}
|
|
481
|
+
export function decodeWsTerminalResizeMessage(rawInput: unknown): WsTerminalResizeMessage | null {
|
|
482
|
+
if (isJSON(rawInput)) {
|
|
483
|
+
const decodedType = decodeString(rawInput['type']);
|
|
484
|
+
const decodedCols = decodeNumber(rawInput['cols']);
|
|
485
|
+
const decodedRows = decodeNumber(rawInput['rows']);
|
|
1331
486
|
|
|
487
|
+
if (decodedType === null || decodedCols === null || decodedRows === null) {
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
1332
490
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
491
|
+
return {
|
|
492
|
+
type: decodedType,
|
|
493
|
+
cols: decodedCols,
|
|
494
|
+
rows: decodedRows,
|
|
495
|
+
};
|
|
1337
496
|
}
|
|
497
|
+
return null;
|
|
1338
498
|
}
|
|
1339
499
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
500
|
+
/**
|
|
501
|
+
* @type { WsTerminalSignalMessage }
|
|
502
|
+
* @description Send a signal to the terminal process
|
|
503
|
+
*/
|
|
504
|
+
export type WsTerminalSignalMessage = {
|
|
505
|
+
/**
|
|
506
|
+
* @type { string }
|
|
507
|
+
* @memberof WsTerminalSignalMessage
|
|
508
|
+
*/
|
|
509
|
+
type: string;
|
|
510
|
+
/**
|
|
511
|
+
* @description Signal name to send to the terminal process
|
|
512
|
+
* @type { SignalEnum }
|
|
513
|
+
* @memberof WsTerminalSignalMessage
|
|
514
|
+
*/
|
|
515
|
+
signal: SignalEnum;
|
|
516
|
+
};
|
|
1346
517
|
|
|
518
|
+
export function decodeWsTerminalSignalMessage(rawInput: unknown): WsTerminalSignalMessage | null {
|
|
519
|
+
if (isJSON(rawInput)) {
|
|
520
|
+
const decodedType = decodeString(rawInput['type']);
|
|
521
|
+
const decodedSignal = decodeSignalEnum(rawInput['signal']);
|
|
1347
522
|
|
|
523
|
+
if (decodedType === null || decodedSignal === null) {
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
1348
526
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
return rawInput;
|
|
527
|
+
return {
|
|
528
|
+
type: decodedType,
|
|
529
|
+
signal: decodedSignal,
|
|
530
|
+
};
|
|
1354
531
|
}
|
|
1355
|
-
return;
|
|
532
|
+
return null;
|
|
1356
533
|
}
|
|
1357
534
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
return rawInput;
|
|
1364
|
-
}
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
535
|
+
/**
|
|
536
|
+
* @type { SignalEnum }
|
|
537
|
+
* @description Signal name to send to the terminal process
|
|
538
|
+
*/
|
|
539
|
+
export type SignalEnum = 'SIGINT' | 'SIGTERM' | 'SIGTSTP';
|
|
1367
540
|
|
|
1368
|
-
export function
|
|
541
|
+
export function decodeSignalEnum(rawInput: unknown): SignalEnum | null {
|
|
1369
542
|
switch (rawInput) {
|
|
1370
|
-
case '
|
|
1371
|
-
case '
|
|
1372
|
-
case '
|
|
1373
|
-
|
|
543
|
+
case 'SIGINT':
|
|
544
|
+
case 'SIGTERM':
|
|
545
|
+
case 'SIGTSTP':
|
|
546
|
+
return rawInput;
|
|
1374
547
|
}
|
|
1375
|
-
return;
|
|
548
|
+
return null;
|
|
1376
549
|
}
|
|
1377
550
|
|
|
1378
|
-
export function
|
|
551
|
+
export function _decodeSignalEnum(rawInput: unknown): SignalEnum | undefined {
|
|
1379
552
|
switch (rawInput) {
|
|
1380
|
-
case '
|
|
1381
|
-
case '
|
|
1382
|
-
|
|
553
|
+
case 'SIGINT':
|
|
554
|
+
case 'SIGTERM':
|
|
555
|
+
case 'SIGTSTP':
|
|
556
|
+
return rawInput;
|
|
1383
557
|
}
|
|
1384
558
|
return;
|
|
1385
559
|
}
|
|
1386
560
|
|
|
561
|
+
export type WsTerminalMessage =
|
|
562
|
+
| CWsTerminalMessageWsTerminalInputMessage
|
|
563
|
+
| CWsTerminalMessageWsTerminalResizeMessage
|
|
564
|
+
| CWsTerminalMessageWsTerminalSignalMessage;
|
|
1387
565
|
|
|
566
|
+
export function decodeWsTerminalMessage(rawInput: unknown): WsTerminalMessage | null {
|
|
567
|
+
const result: WsTerminalMessage | null =
|
|
568
|
+
decodeCWsTerminalMessageWsTerminalInputMessage(rawInput) ??
|
|
569
|
+
decodeCWsTerminalMessageWsTerminalResizeMessage(rawInput) ??
|
|
570
|
+
decodeCWsTerminalMessageWsTerminalSignalMessage(rawInput);
|
|
1388
571
|
|
|
1389
|
-
|
|
1390
|
-
const result = decodeHolderClientMessage1(rawInput);
|
|
1391
|
-
if (result === null) {
|
|
1392
|
-
return null;
|
|
1393
|
-
}
|
|
1394
|
-
return new CHolderClientMessageHolderClientMessage1(result);
|
|
572
|
+
return result;
|
|
1395
573
|
}
|
|
1396
574
|
|
|
1397
|
-
export
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
575
|
+
export class CWsTerminalMessageWsTerminalInputMessage {
|
|
576
|
+
data: WsTerminalInputMessage;
|
|
577
|
+
constructor(data: WsTerminalInputMessage) {
|
|
578
|
+
this.data = data;
|
|
1401
579
|
}
|
|
1402
|
-
return new CHolderClientMessageHolderClientMessage2(result);
|
|
1403
580
|
}
|
|
1404
581
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
const result =
|
|
582
|
+
export function decodeCWsTerminalMessageWsTerminalInputMessage(
|
|
583
|
+
rawInput: unknown
|
|
584
|
+
): CWsTerminalMessageWsTerminalInputMessage | null {
|
|
585
|
+
const result = decodeWsTerminalInputMessage(rawInput);
|
|
1409
586
|
if (result === null) {
|
|
1410
587
|
return null;
|
|
1411
588
|
}
|
|
1412
|
-
return new
|
|
589
|
+
return new CWsTerminalMessageWsTerminalInputMessage(result);
|
|
1413
590
|
}
|
|
1414
591
|
|
|
1415
|
-
export
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
592
|
+
export class CWsTerminalMessageWsTerminalResizeMessage {
|
|
593
|
+
data: WsTerminalResizeMessage;
|
|
594
|
+
constructor(data: WsTerminalResizeMessage) {
|
|
595
|
+
this.data = data;
|
|
1419
596
|
}
|
|
1420
|
-
return new CHolderClientMessageHolderClientMessage4(result);
|
|
1421
597
|
}
|
|
1422
598
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
const result =
|
|
599
|
+
export function decodeCWsTerminalMessageWsTerminalResizeMessage(
|
|
600
|
+
rawInput: unknown
|
|
601
|
+
): CWsTerminalMessageWsTerminalResizeMessage | null {
|
|
602
|
+
const result = decodeWsTerminalResizeMessage(rawInput);
|
|
1427
603
|
if (result === null) {
|
|
1428
604
|
return null;
|
|
1429
605
|
}
|
|
1430
|
-
return new
|
|
606
|
+
return new CWsTerminalMessageWsTerminalResizeMessage(result);
|
|
1431
607
|
}
|
|
1432
608
|
|
|
1433
|
-
export
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
609
|
+
export class CWsTerminalMessageWsTerminalSignalMessage {
|
|
610
|
+
data: WsTerminalSignalMessage;
|
|
611
|
+
constructor(data: WsTerminalSignalMessage) {
|
|
612
|
+
this.data = data;
|
|
1437
613
|
}
|
|
1438
|
-
return new CHolderClientMessageHolderClientMessage6(result);
|
|
1439
614
|
}
|
|
1440
615
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const result =
|
|
616
|
+
export function decodeCWsTerminalMessageWsTerminalSignalMessage(
|
|
617
|
+
rawInput: unknown
|
|
618
|
+
): CWsTerminalMessageWsTerminalSignalMessage | null {
|
|
619
|
+
const result = decodeWsTerminalSignalMessage(rawInput);
|
|
1445
620
|
if (result === null) {
|
|
1446
621
|
return null;
|
|
1447
622
|
}
|
|
1448
|
-
return new
|
|
623
|
+
return new CWsTerminalMessageWsTerminalSignalMessage(result);
|
|
1449
624
|
}
|
|
1450
625
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
626
|
+
/**
|
|
627
|
+
* @type { WsTerminalOutputData }
|
|
628
|
+
* @description Terminal output data from the PTY
|
|
629
|
+
*/
|
|
630
|
+
export type WsTerminalOutputData = {
|
|
631
|
+
/**
|
|
632
|
+
* @type { string }
|
|
633
|
+
* @memberof WsTerminalOutputData
|
|
634
|
+
*/
|
|
635
|
+
type: string;
|
|
636
|
+
/**
|
|
637
|
+
* @description Raw terminal output data
|
|
638
|
+
* @type { string }
|
|
639
|
+
* @memberof WsTerminalOutputData
|
|
640
|
+
*/
|
|
641
|
+
data: string;
|
|
642
|
+
};
|
|
1458
643
|
|
|
644
|
+
export function decodeWsTerminalOutputData(rawInput: unknown): WsTerminalOutputData | null {
|
|
645
|
+
if (isJSON(rawInput)) {
|
|
646
|
+
const decodedType = decodeString(rawInput['type']);
|
|
647
|
+
const decodedData = decodeString(rawInput['data']);
|
|
1459
648
|
|
|
649
|
+
if (decodedType === null || decodedData === null) {
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
1460
652
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
653
|
+
return {
|
|
654
|
+
type: decodedType,
|
|
655
|
+
data: decodedData,
|
|
656
|
+
};
|
|
1465
657
|
}
|
|
1466
|
-
return
|
|
658
|
+
return null;
|
|
1467
659
|
}
|
|
1468
660
|
|
|
1469
|
-
|
|
661
|
+
/**
|
|
662
|
+
* @type { WsTerminalExitData }
|
|
663
|
+
* @description Terminal process has exited
|
|
664
|
+
*/
|
|
665
|
+
export type WsTerminalExitData = {
|
|
666
|
+
/**
|
|
667
|
+
* @type { string }
|
|
668
|
+
* @memberof WsTerminalExitData
|
|
669
|
+
*/
|
|
670
|
+
type: string;
|
|
671
|
+
/**
|
|
672
|
+
* @description Process exit code, or null if terminated by signal
|
|
673
|
+
* @type { number }
|
|
674
|
+
* @memberof WsTerminalExitData
|
|
675
|
+
*/
|
|
676
|
+
code: number | null;
|
|
677
|
+
/**
|
|
678
|
+
* @description Signal that caused the exit, or null if exited normally
|
|
679
|
+
* @type { string }
|
|
680
|
+
* @memberof WsTerminalExitData
|
|
681
|
+
*/
|
|
682
|
+
signal: string | null;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
export function decodeWsTerminalExitData(rawInput: unknown): WsTerminalExitData | null {
|
|
1470
686
|
if (isJSON(rawInput)) {
|
|
1471
|
-
const
|
|
1472
|
-
const
|
|
1473
|
-
const
|
|
1474
|
-
const decodedCols = decodeNumber(rawInput.cols);
|
|
1475
|
-
const decodedRows = decodeNumber(rawInput.rows);
|
|
687
|
+
const decodedType = decodeString(rawInput['type']);
|
|
688
|
+
const decodedCode = decodeNumber(rawInput['code']);
|
|
689
|
+
const decodedSignal = decodeString(rawInput['signal']);
|
|
1476
690
|
|
|
1477
|
-
if (
|
|
1478
|
-
decodedCommand === null ||
|
|
1479
|
-
decodedCwd === null
|
|
1480
|
-
) {
|
|
691
|
+
if (decodedType === null) {
|
|
1481
692
|
return null;
|
|
1482
693
|
}
|
|
1483
694
|
|
|
1484
695
|
return {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
cwd: decodedCwd,
|
|
1489
|
-
rows: decodedRows
|
|
696
|
+
type: decodedType,
|
|
697
|
+
code: decodedCode,
|
|
698
|
+
signal: decodedSignal,
|
|
1490
699
|
};
|
|
1491
700
|
}
|
|
1492
701
|
return null;
|
|
1493
702
|
}
|
|
1494
703
|
|
|
704
|
+
/**
|
|
705
|
+
* @type { WsTerminalScrollbackData }
|
|
706
|
+
* @description Scrollback chunk sent on reconnection
|
|
707
|
+
*/
|
|
708
|
+
export type WsTerminalScrollbackData = {
|
|
709
|
+
/**
|
|
710
|
+
* @type { string }
|
|
711
|
+
* @memberof WsTerminalScrollbackData
|
|
712
|
+
*/
|
|
713
|
+
type: string;
|
|
714
|
+
/**
|
|
715
|
+
* @description Scrollback content for this chunk (max 50KB)
|
|
716
|
+
* @type { string }
|
|
717
|
+
* @memberof WsTerminalScrollbackData
|
|
718
|
+
*/
|
|
719
|
+
data: string;
|
|
720
|
+
/**
|
|
721
|
+
* @description 1-based chunk index
|
|
722
|
+
* @type { number }
|
|
723
|
+
* @memberof WsTerminalScrollbackData
|
|
724
|
+
*/
|
|
725
|
+
chunk: number;
|
|
726
|
+
/**
|
|
727
|
+
* @description Total number of scrollback chunks
|
|
728
|
+
* @type { number }
|
|
729
|
+
* @memberof WsTerminalScrollbackData
|
|
730
|
+
*/
|
|
731
|
+
total: number;
|
|
732
|
+
};
|
|
1495
733
|
|
|
1496
|
-
|
|
1497
|
-
export function decodeCreateTerminalResponse(rawInput: unknown): CreateTerminalResponse | null {
|
|
734
|
+
export function decodeWsTerminalScrollbackData(rawInput: unknown): WsTerminalScrollbackData | null {
|
|
1498
735
|
if (isJSON(rawInput)) {
|
|
1499
|
-
const
|
|
1500
|
-
const
|
|
1501
|
-
const
|
|
1502
|
-
const
|
|
1503
|
-
const decodedWs = decodeString(rawInput.ws);
|
|
1504
|
-
const decodedSessionWs = decodeString(rawInput.sessionWs);
|
|
1505
|
-
const decodedCreatedAt = decodeString(rawInput.createdAt);
|
|
736
|
+
const decodedType = decodeString(rawInput['type']);
|
|
737
|
+
const decodedData = decodeString(rawInput['data']);
|
|
738
|
+
const decodedChunk = decodeNumber(rawInput['chunk']);
|
|
739
|
+
const decodedTotal = decodeNumber(rawInput['total']);
|
|
1506
740
|
|
|
1507
741
|
if (
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
decodedWs === null ||
|
|
1513
|
-
decodedCreatedAt === null
|
|
742
|
+
decodedType === null ||
|
|
743
|
+
decodedData === null ||
|
|
744
|
+
decodedChunk === null ||
|
|
745
|
+
decodedTotal === null
|
|
1514
746
|
) {
|
|
1515
747
|
return null;
|
|
1516
748
|
}
|
|
1517
749
|
|
|
1518
750
|
return {
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
pid: decodedPid,
|
|
1524
|
-
sessionWs: decodedSessionWs,
|
|
1525
|
-
ws: decodedWs
|
|
751
|
+
type: decodedType,
|
|
752
|
+
data: decodedData,
|
|
753
|
+
chunk: decodedChunk,
|
|
754
|
+
total: decodedTotal,
|
|
1526
755
|
};
|
|
1527
756
|
}
|
|
1528
757
|
return null;
|
|
1529
758
|
}
|
|
1530
759
|
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
|
|
760
|
+
/**
|
|
761
|
+
* @type { WsTerminalErrorData }
|
|
762
|
+
* @description Error message from the terminal server
|
|
763
|
+
*/
|
|
764
|
+
export type WsTerminalErrorData = {
|
|
765
|
+
/**
|
|
766
|
+
* @type { string }
|
|
767
|
+
* @memberof WsTerminalErrorData
|
|
768
|
+
*/
|
|
769
|
+
type: string;
|
|
770
|
+
/**
|
|
771
|
+
* @description Human-readable error message
|
|
772
|
+
* @type { string }
|
|
773
|
+
* @memberof WsTerminalErrorData
|
|
774
|
+
*/
|
|
775
|
+
message: string;
|
|
776
|
+
};
|
|
1539
777
|
|
|
778
|
+
export function decodeWsTerminalErrorData(rawInput: unknown): WsTerminalErrorData | null {
|
|
779
|
+
if (isJSON(rawInput)) {
|
|
780
|
+
const decodedType = decodeString(rawInput['type']);
|
|
781
|
+
const decodedMessage = decodeString(rawInput['message']);
|
|
1540
782
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
return null;
|
|
1545
|
-
}
|
|
1546
|
-
return new CWsEventWsEvent2(result);
|
|
1547
|
-
}
|
|
783
|
+
if (decodedType === null || decodedMessage === null) {
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
1548
786
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
787
|
+
return {
|
|
788
|
+
type: decodedType,
|
|
789
|
+
message: decodedMessage,
|
|
790
|
+
};
|
|
1553
791
|
}
|
|
1554
|
-
return
|
|
792
|
+
return null;
|
|
1555
793
|
}
|
|
1556
794
|
|
|
795
|
+
/**
|
|
796
|
+
* @type { WsTerminalOutputDroppedData }
|
|
797
|
+
* @description Notification that output was dropped due to backpressure
|
|
798
|
+
*/
|
|
799
|
+
export type WsTerminalOutputDroppedData = {
|
|
800
|
+
/**
|
|
801
|
+
* @type { string }
|
|
802
|
+
* @memberof WsTerminalOutputDroppedData
|
|
803
|
+
*/
|
|
804
|
+
type: string;
|
|
805
|
+
/**
|
|
806
|
+
* @description Number of bytes that were dropped
|
|
807
|
+
* @type { number }
|
|
808
|
+
* @memberof WsTerminalOutputDroppedData
|
|
809
|
+
*/
|
|
810
|
+
bytes: number;
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
export function decodeWsTerminalOutputDroppedData(
|
|
814
|
+
rawInput: unknown
|
|
815
|
+
): WsTerminalOutputDroppedData | null {
|
|
816
|
+
if (isJSON(rawInput)) {
|
|
817
|
+
const decodedType = decodeString(rawInput['type']);
|
|
818
|
+
const decodedBytes = decodeNumber(rawInput['bytes']);
|
|
1557
819
|
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
return null;
|
|
1562
|
-
}
|
|
1563
|
-
return new CWsEventWsEvent4(result);
|
|
1564
|
-
}
|
|
820
|
+
if (decodedType === null || decodedBytes === null) {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
1565
823
|
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
824
|
+
return {
|
|
825
|
+
type: decodedType,
|
|
826
|
+
bytes: decodedBytes,
|
|
827
|
+
};
|
|
1570
828
|
}
|
|
1571
|
-
return
|
|
829
|
+
return null;
|
|
1572
830
|
}
|
|
1573
831
|
|
|
832
|
+
/**
|
|
833
|
+
* @type { WsTerminalActivityData }
|
|
834
|
+
* @description Terminal activity state change (active/idle)
|
|
835
|
+
*/
|
|
836
|
+
export type WsTerminalActivityData = {
|
|
837
|
+
/**
|
|
838
|
+
* @type { string }
|
|
839
|
+
* @memberof WsTerminalActivityData
|
|
840
|
+
*/
|
|
841
|
+
type: string;
|
|
842
|
+
/**
|
|
843
|
+
* @description Whether the terminal is currently producing output
|
|
844
|
+
* @type { boolean }
|
|
845
|
+
* @memberof WsTerminalActivityData
|
|
846
|
+
*/
|
|
847
|
+
active: boolean;
|
|
848
|
+
};
|
|
1574
849
|
|
|
850
|
+
export function decodeWsTerminalActivityData(rawInput: unknown): WsTerminalActivityData | null {
|
|
851
|
+
if (isJSON(rawInput)) {
|
|
852
|
+
const decodedType = decodeString(rawInput['type']);
|
|
853
|
+
const decodedActive = decodeBoolean(rawInput['active']);
|
|
1575
854
|
|
|
855
|
+
if (decodedType === null || decodedActive === null) {
|
|
856
|
+
return null;
|
|
857
|
+
}
|
|
1576
858
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
859
|
+
return {
|
|
860
|
+
type: decodedType,
|
|
861
|
+
active: decodedActive,
|
|
862
|
+
};
|
|
1581
863
|
}
|
|
1582
|
-
return
|
|
864
|
+
return null;
|
|
1583
865
|
}
|
|
1584
866
|
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
867
|
+
/**
|
|
868
|
+
* @type { WsTerminalCwdData }
|
|
869
|
+
* @description Current working directory change detected via OSC 7
|
|
870
|
+
*/
|
|
871
|
+
export type WsTerminalCwdData = {
|
|
872
|
+
/**
|
|
873
|
+
* @type { string }
|
|
874
|
+
* @memberof WsTerminalCwdData
|
|
875
|
+
*/
|
|
876
|
+
type: string;
|
|
877
|
+
/**
|
|
878
|
+
* @description Absolute path of the new working directory
|
|
879
|
+
* @type { string }
|
|
880
|
+
* @memberof WsTerminalCwdData
|
|
881
|
+
*/
|
|
882
|
+
path: string;
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
export function decodeWsTerminalCwdData(rawInput: unknown): WsTerminalCwdData | null {
|
|
886
|
+
if (isJSON(rawInput)) {
|
|
887
|
+
const decodedType = decodeString(rawInput['type']);
|
|
888
|
+
const decodedPath = decodeString(rawInput['path']);
|
|
889
|
+
|
|
890
|
+
if (decodedType === null || decodedPath === null) {
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return {
|
|
895
|
+
type: decodedType,
|
|
896
|
+
path: decodedPath,
|
|
897
|
+
};
|
|
1589
898
|
}
|
|
1590
|
-
return
|
|
899
|
+
return null;
|
|
1591
900
|
}
|
|
1592
901
|
|
|
902
|
+
export type WsTerminalOutput =
|
|
903
|
+
| CWsTerminalOutputWsTerminalOutputData
|
|
904
|
+
| CWsTerminalOutputWsTerminalExitData
|
|
905
|
+
| CWsTerminalOutputWsTerminalScrollbackData
|
|
906
|
+
| CWsTerminalOutputWsTerminalErrorData
|
|
907
|
+
| CWsTerminalOutputWsTerminalOutputDroppedData
|
|
908
|
+
| CWsTerminalOutputWsTerminalActivityData
|
|
909
|
+
| CWsTerminalOutputWsTerminalCwdData;
|
|
910
|
+
|
|
911
|
+
export function decodeWsTerminalOutput(rawInput: unknown): WsTerminalOutput | null {
|
|
912
|
+
const result: WsTerminalOutput | null =
|
|
913
|
+
decodeCWsTerminalOutputWsTerminalOutputData(rawInput) ??
|
|
914
|
+
decodeCWsTerminalOutputWsTerminalExitData(rawInput) ??
|
|
915
|
+
decodeCWsTerminalOutputWsTerminalScrollbackData(rawInput) ??
|
|
916
|
+
decodeCWsTerminalOutputWsTerminalErrorData(rawInput) ??
|
|
917
|
+
decodeCWsTerminalOutputWsTerminalOutputDroppedData(rawInput) ??
|
|
918
|
+
decodeCWsTerminalOutputWsTerminalActivityData(rawInput) ??
|
|
919
|
+
decodeCWsTerminalOutputWsTerminalCwdData(rawInput);
|
|
1593
920
|
|
|
921
|
+
return result;
|
|
922
|
+
}
|
|
1594
923
|
|
|
1595
|
-
export
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
924
|
+
export class CWsTerminalOutputWsTerminalOutputData {
|
|
925
|
+
data: WsTerminalOutputData;
|
|
926
|
+
constructor(data: WsTerminalOutputData) {
|
|
927
|
+
this.data = data;
|
|
1599
928
|
}
|
|
1600
|
-
return new CWsSessionMessageWsSessionMessage3(result);
|
|
1601
929
|
}
|
|
1602
930
|
|
|
1603
|
-
export function
|
|
1604
|
-
|
|
931
|
+
export function decodeCWsTerminalOutputWsTerminalOutputData(
|
|
932
|
+
rawInput: unknown
|
|
933
|
+
): CWsTerminalOutputWsTerminalOutputData | null {
|
|
934
|
+
const result = decodeWsTerminalOutputData(rawInput);
|
|
1605
935
|
if (result === null) {
|
|
1606
936
|
return null;
|
|
1607
937
|
}
|
|
1608
|
-
return new
|
|
938
|
+
return new CWsTerminalOutputWsTerminalOutputData(result);
|
|
1609
939
|
}
|
|
1610
940
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
if (result === null) {
|
|
1616
|
-
return null;
|
|
941
|
+
export class CWsTerminalOutputWsTerminalExitData {
|
|
942
|
+
data: WsTerminalExitData;
|
|
943
|
+
constructor(data: WsTerminalExitData) {
|
|
944
|
+
this.data = data;
|
|
1617
945
|
}
|
|
1618
|
-
return new CWsSessionOutputWsSessionOutput2(result);
|
|
1619
946
|
}
|
|
1620
947
|
|
|
1621
|
-
export function
|
|
1622
|
-
|
|
948
|
+
export function decodeCWsTerminalOutputWsTerminalExitData(
|
|
949
|
+
rawInput: unknown
|
|
950
|
+
): CWsTerminalOutputWsTerminalExitData | null {
|
|
951
|
+
const result = decodeWsTerminalExitData(rawInput);
|
|
1623
952
|
if (result === null) {
|
|
1624
953
|
return null;
|
|
1625
954
|
}
|
|
1626
|
-
return new
|
|
955
|
+
return new CWsTerminalOutputWsTerminalExitData(result);
|
|
1627
956
|
}
|
|
1628
957
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
if (result === null) {
|
|
1634
|
-
return null;
|
|
958
|
+
export class CWsTerminalOutputWsTerminalScrollbackData {
|
|
959
|
+
data: WsTerminalScrollbackData;
|
|
960
|
+
constructor(data: WsTerminalScrollbackData) {
|
|
961
|
+
this.data = data;
|
|
1635
962
|
}
|
|
1636
|
-
return new CWsSessionOutputWsSessionOutput4(result);
|
|
1637
963
|
}
|
|
1638
964
|
|
|
1639
|
-
export function
|
|
1640
|
-
|
|
965
|
+
export function decodeCWsTerminalOutputWsTerminalScrollbackData(
|
|
966
|
+
rawInput: unknown
|
|
967
|
+
): CWsTerminalOutputWsTerminalScrollbackData | null {
|
|
968
|
+
const result = decodeWsTerminalScrollbackData(rawInput);
|
|
1641
969
|
if (result === null) {
|
|
1642
970
|
return null;
|
|
1643
971
|
}
|
|
1644
|
-
return new
|
|
972
|
+
return new CWsTerminalOutputWsTerminalScrollbackData(result);
|
|
1645
973
|
}
|
|
1646
974
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
if (result === null) {
|
|
1652
|
-
return null;
|
|
975
|
+
export class CWsTerminalOutputWsTerminalErrorData {
|
|
976
|
+
data: WsTerminalErrorData;
|
|
977
|
+
constructor(data: WsTerminalErrorData) {
|
|
978
|
+
this.data = data;
|
|
1653
979
|
}
|
|
1654
|
-
return new CWsSessionOutputWsSessionOutput6(result);
|
|
1655
980
|
}
|
|
1656
981
|
|
|
1657
|
-
export function
|
|
1658
|
-
|
|
982
|
+
export function decodeCWsTerminalOutputWsTerminalErrorData(
|
|
983
|
+
rawInput: unknown
|
|
984
|
+
): CWsTerminalOutputWsTerminalErrorData | null {
|
|
985
|
+
const result = decodeWsTerminalErrorData(rawInput);
|
|
1659
986
|
if (result === null) {
|
|
1660
987
|
return null;
|
|
1661
988
|
}
|
|
1662
|
-
return new
|
|
989
|
+
return new CWsTerminalOutputWsTerminalErrorData(result);
|
|
1663
990
|
}
|
|
1664
991
|
|
|
1665
|
-
export
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
992
|
+
export class CWsTerminalOutputWsTerminalOutputDroppedData {
|
|
993
|
+
data: WsTerminalOutputDroppedData;
|
|
994
|
+
constructor(data: WsTerminalOutputDroppedData) {
|
|
995
|
+
this.data = data;
|
|
1669
996
|
}
|
|
1670
|
-
return new CWsTerminalMessageWsTerminalMessage2(result);
|
|
1671
997
|
}
|
|
1672
998
|
|
|
1673
|
-
export function
|
|
1674
|
-
|
|
999
|
+
export function decodeCWsTerminalOutputWsTerminalOutputDroppedData(
|
|
1000
|
+
rawInput: unknown
|
|
1001
|
+
): CWsTerminalOutputWsTerminalOutputDroppedData | null {
|
|
1002
|
+
const result = decodeWsTerminalOutputDroppedData(rawInput);
|
|
1675
1003
|
if (result === null) {
|
|
1676
1004
|
return null;
|
|
1677
1005
|
}
|
|
1678
|
-
return new
|
|
1006
|
+
return new CWsTerminalOutputWsTerminalOutputDroppedData(result);
|
|
1679
1007
|
}
|
|
1680
1008
|
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
if (result === null) {
|
|
1686
|
-
return null;
|
|
1009
|
+
export class CWsTerminalOutputWsTerminalActivityData {
|
|
1010
|
+
data: WsTerminalActivityData;
|
|
1011
|
+
constructor(data: WsTerminalActivityData) {
|
|
1012
|
+
this.data = data;
|
|
1687
1013
|
}
|
|
1688
|
-
return new CWsTerminalOutputWsTerminalOutput1(result);
|
|
1689
1014
|
}
|
|
1690
1015
|
|
|
1691
|
-
export function
|
|
1692
|
-
|
|
1016
|
+
export function decodeCWsTerminalOutputWsTerminalActivityData(
|
|
1017
|
+
rawInput: unknown
|
|
1018
|
+
): CWsTerminalOutputWsTerminalActivityData | null {
|
|
1019
|
+
const result = decodeWsTerminalActivityData(rawInput);
|
|
1693
1020
|
if (result === null) {
|
|
1694
1021
|
return null;
|
|
1695
1022
|
}
|
|
1696
|
-
return new
|
|
1023
|
+
return new CWsTerminalOutputWsTerminalActivityData(result);
|
|
1697
1024
|
}
|
|
1698
1025
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
if (result === null) {
|
|
1704
|
-
return null;
|
|
1026
|
+
export class CWsTerminalOutputWsTerminalCwdData {
|
|
1027
|
+
data: WsTerminalCwdData;
|
|
1028
|
+
constructor(data: WsTerminalCwdData) {
|
|
1029
|
+
this.data = data;
|
|
1705
1030
|
}
|
|
1706
|
-
return new CWsTerminalOutputWsTerminalOutput3(result);
|
|
1707
1031
|
}
|
|
1708
1032
|
|
|
1709
|
-
export function
|
|
1710
|
-
|
|
1033
|
+
export function decodeCWsTerminalOutputWsTerminalCwdData(
|
|
1034
|
+
rawInput: unknown
|
|
1035
|
+
): CWsTerminalOutputWsTerminalCwdData | null {
|
|
1036
|
+
const result = decodeWsTerminalCwdData(rawInput);
|
|
1711
1037
|
if (result === null) {
|
|
1712
1038
|
return null;
|
|
1713
1039
|
}
|
|
1714
|
-
return new
|
|
1040
|
+
return new CWsTerminalOutputWsTerminalCwdData(result);
|
|
1715
1041
|
}
|
|
1716
1042
|
|
|
1043
|
+
/**
|
|
1044
|
+
* @type { WsSessionSubscribeMessage }
|
|
1045
|
+
* @description Subscribe to a live AI session stream
|
|
1046
|
+
*/
|
|
1047
|
+
export type WsSessionSubscribeMessage = {
|
|
1048
|
+
/**
|
|
1049
|
+
* @type { string }
|
|
1050
|
+
* @memberof WsSessionSubscribeMessage
|
|
1051
|
+
*/
|
|
1052
|
+
type: string;
|
|
1053
|
+
/**
|
|
1054
|
+
* @description Terminal ID used to find the associated session file for streaming
|
|
1055
|
+
* @type { string }
|
|
1056
|
+
* @memberof WsSessionSubscribeMessage
|
|
1057
|
+
*/
|
|
1058
|
+
sessionId: string;
|
|
1059
|
+
};
|
|
1717
1060
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
decodeCHolderClientMessage1(rawInput)
|
|
1722
|
-
??
|
|
1723
|
-
decodeCHolderClientMessage2(rawInput)
|
|
1724
|
-
??
|
|
1725
|
-
decodeCHolderClientMessage3(rawInput)
|
|
1726
|
-
??
|
|
1727
|
-
decodeCHolderClientMessage4(rawInput)
|
|
1728
|
-
??
|
|
1729
|
-
decodeCHolderClientMessage5(rawInput)
|
|
1730
|
-
??
|
|
1731
|
-
decodeCHolderClientMessage6(rawInput)
|
|
1732
|
-
|
|
1733
|
-
;
|
|
1734
|
-
return result;
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
export function decodeHolderClientMessage1(rawInput: unknown): HolderClientMessage1 | null {
|
|
1061
|
+
export function decodeWsSessionSubscribeMessage(
|
|
1062
|
+
rawInput: unknown
|
|
1063
|
+
): WsSessionSubscribeMessage | null {
|
|
1738
1064
|
if (isJSON(rawInput)) {
|
|
1739
|
-
const decodedType = decodeString(rawInput
|
|
1740
|
-
const
|
|
1741
|
-
const decodedExited = decodeBoolean(rawInput.exited);
|
|
1742
|
-
const decodedExitCode = decodeNumber(rawInput.exitCode);
|
|
1065
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1066
|
+
const decodedSessionId = decodeString(rawInput['sessionId']);
|
|
1743
1067
|
|
|
1744
|
-
if (
|
|
1745
|
-
decodedType === null ||
|
|
1746
|
-
decodedPid === null ||
|
|
1747
|
-
decodedExited === null
|
|
1748
|
-
) {
|
|
1068
|
+
if (decodedType === null || decodedSessionId === null) {
|
|
1749
1069
|
return null;
|
|
1750
1070
|
}
|
|
1751
1071
|
|
|
1752
1072
|
return {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
pid: decodedPid,
|
|
1756
|
-
type: decodedType
|
|
1073
|
+
type: decodedType,
|
|
1074
|
+
sessionId: decodedSessionId,
|
|
1757
1075
|
};
|
|
1758
1076
|
}
|
|
1759
1077
|
return null;
|
|
1760
1078
|
}
|
|
1761
1079
|
|
|
1080
|
+
/**
|
|
1081
|
+
* @type { WsSessionSendInputMessage }
|
|
1082
|
+
* @description Send text input to the AI session (writes to PTY stdin with newline)
|
|
1083
|
+
*/
|
|
1084
|
+
export type WsSessionSendInputMessage = {
|
|
1085
|
+
/**
|
|
1086
|
+
* @type { string }
|
|
1087
|
+
* @memberof WsSessionSendInputMessage
|
|
1088
|
+
*/
|
|
1089
|
+
type: string;
|
|
1090
|
+
/**
|
|
1091
|
+
* @description Text to send to the AI session (max 10KB)
|
|
1092
|
+
* @type { string }
|
|
1093
|
+
* @memberof WsSessionSendInputMessage
|
|
1094
|
+
*/
|
|
1095
|
+
text: string;
|
|
1096
|
+
};
|
|
1762
1097
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1098
|
+
export function decodeWsSessionSendInputMessage(
|
|
1099
|
+
rawInput: unknown
|
|
1100
|
+
): WsSessionSendInputMessage | null {
|
|
1765
1101
|
if (isJSON(rawInput)) {
|
|
1766
|
-
const decodedType = decodeString(rawInput
|
|
1767
|
-
const
|
|
1102
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1103
|
+
const decodedText = decodeString(rawInput['text']);
|
|
1768
1104
|
|
|
1769
|
-
if (
|
|
1770
|
-
decodedType === null ||
|
|
1771
|
-
decodedData === null
|
|
1772
|
-
) {
|
|
1105
|
+
if (decodedType === null || decodedText === null) {
|
|
1773
1106
|
return null;
|
|
1774
1107
|
}
|
|
1775
1108
|
|
|
1776
1109
|
return {
|
|
1777
|
-
|
|
1778
|
-
|
|
1110
|
+
type: decodedType,
|
|
1111
|
+
text: decodedText,
|
|
1779
1112
|
};
|
|
1780
1113
|
}
|
|
1781
1114
|
return null;
|
|
1782
1115
|
}
|
|
1783
1116
|
|
|
1784
|
-
|
|
1117
|
+
/**
|
|
1118
|
+
* @type { WsSessionCancelMessage }
|
|
1119
|
+
* @description Cancel the current AI operation (sends SIGINT to PTY)
|
|
1120
|
+
*/
|
|
1121
|
+
export type WsSessionCancelMessage = {
|
|
1122
|
+
/**
|
|
1123
|
+
* @type { string }
|
|
1124
|
+
* @memberof WsSessionCancelMessage
|
|
1125
|
+
*/
|
|
1126
|
+
type: string;
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
export function decodeWsSessionCancelMessage(rawInput: unknown): WsSessionCancelMessage | null {
|
|
1785
1130
|
if (isJSON(rawInput)) {
|
|
1786
|
-
const decodedType = decodeString(rawInput
|
|
1787
|
-
const decodedData = decodeString(rawInput.data);
|
|
1131
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1788
1132
|
|
|
1789
|
-
if (
|
|
1790
|
-
decodedType === null ||
|
|
1791
|
-
decodedData === null
|
|
1792
|
-
) {
|
|
1133
|
+
if (decodedType === null) {
|
|
1793
1134
|
return null;
|
|
1794
1135
|
}
|
|
1795
1136
|
|
|
1796
1137
|
return {
|
|
1797
|
-
|
|
1798
|
-
type: decodedType
|
|
1138
|
+
type: decodedType,
|
|
1799
1139
|
};
|
|
1800
1140
|
}
|
|
1801
1141
|
return null;
|
|
1802
1142
|
}
|
|
1803
1143
|
|
|
1144
|
+
export type WsSessionMessage =
|
|
1145
|
+
| CWsSessionMessageWsSessionSubscribeMessage
|
|
1146
|
+
| CWsSessionMessageWsSessionSendInputMessage
|
|
1147
|
+
| CWsSessionMessageWsSessionCancelMessage;
|
|
1804
1148
|
|
|
1149
|
+
export function decodeWsSessionMessage(rawInput: unknown): WsSessionMessage | null {
|
|
1150
|
+
const result: WsSessionMessage | null =
|
|
1151
|
+
decodeCWsSessionMessageWsSessionSubscribeMessage(rawInput) ??
|
|
1152
|
+
decodeCWsSessionMessageWsSessionSendInputMessage(rawInput) ??
|
|
1153
|
+
decodeCWsSessionMessageWsSessionCancelMessage(rawInput);
|
|
1805
1154
|
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
const decodedType = decodeString(rawInput.type);
|
|
1809
|
-
const decodedCode = decodeNumber(rawInput.code);
|
|
1810
|
-
const decodedSignal = decodeString(rawInput.signal);
|
|
1155
|
+
return result;
|
|
1156
|
+
}
|
|
1811
1157
|
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1158
|
+
export class CWsSessionMessageWsSessionSubscribeMessage {
|
|
1159
|
+
data: WsSessionSubscribeMessage;
|
|
1160
|
+
constructor(data: WsSessionSubscribeMessage) {
|
|
1161
|
+
this.data = data;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1818
1164
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1165
|
+
export function decodeCWsSessionMessageWsSessionSubscribeMessage(
|
|
1166
|
+
rawInput: unknown
|
|
1167
|
+
): CWsSessionMessageWsSessionSubscribeMessage | null {
|
|
1168
|
+
const result = decodeWsSessionSubscribeMessage(rawInput);
|
|
1169
|
+
if (result === null) {
|
|
1170
|
+
return null;
|
|
1824
1171
|
}
|
|
1825
|
-
return
|
|
1172
|
+
return new CWsSessionMessageWsSessionSubscribeMessage(result);
|
|
1826
1173
|
}
|
|
1827
1174
|
|
|
1828
|
-
export
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1175
|
+
export class CWsSessionMessageWsSessionSendInputMessage {
|
|
1176
|
+
data: WsSessionSendInputMessage;
|
|
1177
|
+
constructor(data: WsSessionSendInputMessage) {
|
|
1178
|
+
this.data = data;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1832
1181
|
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1182
|
+
export function decodeCWsSessionMessageWsSessionSendInputMessage(
|
|
1183
|
+
rawInput: unknown
|
|
1184
|
+
): CWsSessionMessageWsSessionSendInputMessage | null {
|
|
1185
|
+
const result = decodeWsSessionSendInputMessage(rawInput);
|
|
1186
|
+
if (result === null) {
|
|
1187
|
+
return null;
|
|
1188
|
+
}
|
|
1189
|
+
return new CWsSessionMessageWsSessionSendInputMessage(result);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
export class CWsSessionMessageWsSessionCancelMessage {
|
|
1193
|
+
data: WsSessionCancelMessage;
|
|
1194
|
+
constructor(data: WsSessionCancelMessage) {
|
|
1195
|
+
this.data = data;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
export function decodeCWsSessionMessageWsSessionCancelMessage(
|
|
1200
|
+
rawInput: unknown
|
|
1201
|
+
): CWsSessionMessageWsSessionCancelMessage | null {
|
|
1202
|
+
const result = decodeWsSessionCancelMessage(rawInput);
|
|
1203
|
+
if (result === null) {
|
|
1204
|
+
return null;
|
|
1205
|
+
}
|
|
1206
|
+
return new CWsSessionMessageWsSessionCancelMessage(result);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* @type { SessionMessageItem }
|
|
1211
|
+
* @description A session message entry
|
|
1212
|
+
*/
|
|
1213
|
+
export type SessionMessageItem = Record<string, unknown>;
|
|
1839
1214
|
|
|
1215
|
+
export function decodeSessionMessageItem(rawInput: unknown): SessionMessageItem | null {
|
|
1216
|
+
if (isJSON(rawInput)) {
|
|
1840
1217
|
return {
|
|
1841
|
-
|
|
1842
|
-
type: decodedType
|
|
1218
|
+
...rawInput,
|
|
1843
1219
|
};
|
|
1844
1220
|
}
|
|
1845
1221
|
return null;
|
|
1846
1222
|
}
|
|
1847
1223
|
|
|
1224
|
+
/**
|
|
1225
|
+
* @type { WsSessionHistoryOutput }
|
|
1226
|
+
* @description Full conversation history sent on connect
|
|
1227
|
+
*/
|
|
1228
|
+
export type WsSessionHistoryOutput = {
|
|
1229
|
+
/**
|
|
1230
|
+
* @type { string }
|
|
1231
|
+
* @memberof WsSessionHistoryOutput
|
|
1232
|
+
*/
|
|
1233
|
+
type: string;
|
|
1234
|
+
/**
|
|
1235
|
+
* @description All session messages from the beginning up to the current point
|
|
1236
|
+
* @type { SessionMessageItem[] }
|
|
1237
|
+
* @memberof WsSessionHistoryOutput
|
|
1238
|
+
*/
|
|
1239
|
+
messages: SessionMessageItem[];
|
|
1240
|
+
};
|
|
1848
1241
|
|
|
1849
|
-
export function
|
|
1242
|
+
export function decodeWsSessionHistoryOutput(rawInput: unknown): WsSessionHistoryOutput | null {
|
|
1850
1243
|
if (isJSON(rawInput)) {
|
|
1851
|
-
const decodedType = decodeString(rawInput
|
|
1852
|
-
const
|
|
1244
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1245
|
+
const decodedMessages = decodeArray(rawInput['messages'], decodeSessionMessageItem);
|
|
1853
1246
|
|
|
1854
|
-
if (
|
|
1855
|
-
decodedType === null ||
|
|
1856
|
-
decodedPath === null
|
|
1857
|
-
) {
|
|
1247
|
+
if (decodedType === null || decodedMessages === null) {
|
|
1858
1248
|
return null;
|
|
1859
1249
|
}
|
|
1860
1250
|
|
|
1861
1251
|
return {
|
|
1862
|
-
|
|
1863
|
-
|
|
1252
|
+
type: decodedType,
|
|
1253
|
+
messages: decodedMessages,
|
|
1864
1254
|
};
|
|
1865
1255
|
}
|
|
1866
1256
|
return null;
|
|
1867
1257
|
}
|
|
1868
1258
|
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
??
|
|
1875
|
-
decodeCHolderServerMessage3(rawInput)
|
|
1259
|
+
/**
|
|
1260
|
+
* @type { ContentBlockItem }
|
|
1261
|
+
* @description A content block (text, code, etc.)
|
|
1262
|
+
*/
|
|
1263
|
+
export type ContentBlockItem = Record<string, unknown>;
|
|
1876
1264
|
|
|
1877
|
-
|
|
1878
|
-
|
|
1265
|
+
export function decodeContentBlockItem(rawInput: unknown): ContentBlockItem | null {
|
|
1266
|
+
if (isJSON(rawInput)) {
|
|
1267
|
+
return {
|
|
1268
|
+
...rawInput,
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
return null;
|
|
1879
1272
|
}
|
|
1880
1273
|
|
|
1274
|
+
/**
|
|
1275
|
+
* @type { WsSessionMessageOutput }
|
|
1276
|
+
* @description A new conversation message (user or assistant)
|
|
1277
|
+
*/
|
|
1278
|
+
export type WsSessionMessageOutput = {
|
|
1279
|
+
/**
|
|
1280
|
+
* @type { string }
|
|
1281
|
+
* @memberof WsSessionMessageOutput
|
|
1282
|
+
*/
|
|
1283
|
+
type: string;
|
|
1284
|
+
/**
|
|
1285
|
+
* @description Who sent the message
|
|
1286
|
+
* @type { RoleEnum }
|
|
1287
|
+
* @memberof WsSessionMessageOutput
|
|
1288
|
+
*/
|
|
1289
|
+
role: RoleEnum;
|
|
1290
|
+
/**
|
|
1291
|
+
* @description Message content blocks
|
|
1292
|
+
* @type { ContentBlockItem[] }
|
|
1293
|
+
* @memberof WsSessionMessageOutput
|
|
1294
|
+
*/
|
|
1295
|
+
content: ContentBlockItem[];
|
|
1296
|
+
/**
|
|
1297
|
+
* @description ISO 8601 timestamp of the message
|
|
1298
|
+
* @type { string }
|
|
1299
|
+
* @memberof WsSessionMessageOutput
|
|
1300
|
+
*/
|
|
1301
|
+
timestamp: string;
|
|
1302
|
+
};
|
|
1881
1303
|
|
|
1882
|
-
export function
|
|
1304
|
+
export function decodeWsSessionMessageOutput(rawInput: unknown): WsSessionMessageOutput | null {
|
|
1883
1305
|
if (isJSON(rawInput)) {
|
|
1884
|
-
const decodedType = decodeString(rawInput
|
|
1885
|
-
const
|
|
1306
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1307
|
+
const decodedRole = decodeRoleEnum(rawInput['role']);
|
|
1308
|
+
const decodedContent = decodeArray(rawInput['content'], decodeContentBlockItem);
|
|
1309
|
+
const decodedTimestamp = decodeString(rawInput['timestamp']);
|
|
1886
1310
|
|
|
1887
1311
|
if (
|
|
1888
1312
|
decodedType === null ||
|
|
1889
|
-
|
|
1313
|
+
decodedRole === null ||
|
|
1314
|
+
decodedContent === null ||
|
|
1315
|
+
decodedTimestamp === null
|
|
1890
1316
|
) {
|
|
1891
1317
|
return null;
|
|
1892
1318
|
}
|
|
1893
1319
|
|
|
1894
1320
|
return {
|
|
1895
|
-
|
|
1896
|
-
|
|
1321
|
+
type: decodedType,
|
|
1322
|
+
role: decodedRole,
|
|
1323
|
+
content: decodedContent,
|
|
1324
|
+
timestamp: decodedTimestamp,
|
|
1897
1325
|
};
|
|
1898
1326
|
}
|
|
1899
1327
|
return null;
|
|
1900
1328
|
}
|
|
1901
1329
|
|
|
1902
|
-
|
|
1330
|
+
/**
|
|
1331
|
+
* @type { RoleEnum }
|
|
1332
|
+
* @description Who sent the message
|
|
1333
|
+
*/
|
|
1334
|
+
export type RoleEnum = 'user' | 'assistant';
|
|
1335
|
+
|
|
1336
|
+
export function decodeRoleEnum(rawInput: unknown): RoleEnum | null {
|
|
1337
|
+
switch (rawInput) {
|
|
1338
|
+
case 'user':
|
|
1339
|
+
case 'assistant':
|
|
1340
|
+
return rawInput;
|
|
1341
|
+
}
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
export function _decodeRoleEnum(rawInput: unknown): RoleEnum | undefined {
|
|
1346
|
+
switch (rawInput) {
|
|
1347
|
+
case 'user':
|
|
1348
|
+
case 'assistant':
|
|
1349
|
+
return rawInput;
|
|
1350
|
+
}
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* @type { WsSessionToolUseOutput }
|
|
1356
|
+
* @description A tool invocation by the AI assistant
|
|
1357
|
+
*/
|
|
1358
|
+
export type WsSessionToolUseOutput = {
|
|
1359
|
+
/**
|
|
1360
|
+
* @type { string }
|
|
1361
|
+
* @memberof WsSessionToolUseOutput
|
|
1362
|
+
*/
|
|
1363
|
+
type: string;
|
|
1364
|
+
/**
|
|
1365
|
+
* @description Unique tool use identifier for correlating with tool-result
|
|
1366
|
+
* @type { string }
|
|
1367
|
+
* @memberof WsSessionToolUseOutput
|
|
1368
|
+
*/
|
|
1369
|
+
id: string;
|
|
1370
|
+
/**
|
|
1371
|
+
* @description Tool name (e.g. "Edit", "Bash", "Read")
|
|
1372
|
+
* @type { string }
|
|
1373
|
+
* @memberof WsSessionToolUseOutput
|
|
1374
|
+
*/
|
|
1375
|
+
name: string;
|
|
1376
|
+
/**
|
|
1377
|
+
* @description Tool input parameters
|
|
1378
|
+
* @type { WsSessionToolUseOutputInput }
|
|
1379
|
+
* @memberof WsSessionToolUseOutput
|
|
1380
|
+
*/
|
|
1381
|
+
input: WsSessionToolUseOutputInput;
|
|
1382
|
+
/**
|
|
1383
|
+
* @description Tool use is always emitted with running status
|
|
1384
|
+
* @type { string }
|
|
1385
|
+
* @memberof WsSessionToolUseOutput
|
|
1386
|
+
*/
|
|
1387
|
+
status: string;
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
export function decodeWsSessionToolUseOutput(rawInput: unknown): WsSessionToolUseOutput | null {
|
|
1903
1391
|
if (isJSON(rawInput)) {
|
|
1904
|
-
const decodedType = decodeString(rawInput
|
|
1905
|
-
const
|
|
1906
|
-
const
|
|
1392
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1393
|
+
const decodedId = decodeString(rawInput['id']);
|
|
1394
|
+
const decodedName = decodeString(rawInput['name']);
|
|
1395
|
+
const decodedInput = decodeWsSessionToolUseOutputInput(rawInput['input']);
|
|
1396
|
+
const decodedStatus = decodeString(rawInput['status']);
|
|
1907
1397
|
|
|
1908
1398
|
if (
|
|
1909
1399
|
decodedType === null ||
|
|
1910
|
-
|
|
1911
|
-
|
|
1400
|
+
decodedId === null ||
|
|
1401
|
+
decodedName === null ||
|
|
1402
|
+
decodedInput === null ||
|
|
1403
|
+
decodedStatus === null
|
|
1912
1404
|
) {
|
|
1913
1405
|
return null;
|
|
1914
1406
|
}
|
|
1915
1407
|
|
|
1916
1408
|
return {
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1409
|
+
type: decodedType,
|
|
1410
|
+
id: decodedId,
|
|
1411
|
+
name: decodedName,
|
|
1412
|
+
input: decodedInput,
|
|
1413
|
+
status: decodedStatus,
|
|
1920
1414
|
};
|
|
1921
1415
|
}
|
|
1922
1416
|
return null;
|
|
1923
1417
|
}
|
|
1924
1418
|
|
|
1419
|
+
/**
|
|
1420
|
+
* @type { WsSessionToolUseOutputInput }
|
|
1421
|
+
* @description Tool input parameters
|
|
1422
|
+
*/
|
|
1423
|
+
export type WsSessionToolUseOutputInput = Record<string, unknown>;
|
|
1925
1424
|
|
|
1425
|
+
export function decodeWsSessionToolUseOutputInput(
|
|
1426
|
+
rawInput: unknown
|
|
1427
|
+
): WsSessionToolUseOutputInput | null {
|
|
1428
|
+
if (isJSON(rawInput)) {
|
|
1429
|
+
return {
|
|
1430
|
+
...rawInput,
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
return null;
|
|
1434
|
+
}
|
|
1926
1435
|
|
|
1436
|
+
/**
|
|
1437
|
+
* @type { WsSessionToolResultOutput }
|
|
1438
|
+
* @description Result from a completed tool invocation
|
|
1439
|
+
*/
|
|
1440
|
+
export type WsSessionToolResultOutput = {
|
|
1441
|
+
/**
|
|
1442
|
+
* @type { string }
|
|
1443
|
+
* @memberof WsSessionToolResultOutput
|
|
1444
|
+
*/
|
|
1445
|
+
type: string;
|
|
1446
|
+
/**
|
|
1447
|
+
* @description Tool use ID this result corresponds to
|
|
1448
|
+
* @type { string }
|
|
1449
|
+
* @memberof WsSessionToolResultOutput
|
|
1450
|
+
*/
|
|
1451
|
+
id: string;
|
|
1452
|
+
/**
|
|
1453
|
+
* @description Tool output text
|
|
1454
|
+
* @type { string }
|
|
1455
|
+
* @memberof WsSessionToolResultOutput
|
|
1456
|
+
*/
|
|
1457
|
+
output: string;
|
|
1458
|
+
/**
|
|
1459
|
+
* @description Whether the tool execution resulted in an error
|
|
1460
|
+
* @type { boolean }
|
|
1461
|
+
* @memberof WsSessionToolResultOutput
|
|
1462
|
+
*/
|
|
1463
|
+
isError: boolean;
|
|
1464
|
+
/**
|
|
1465
|
+
* @description Tool result is always emitted with done status
|
|
1466
|
+
* @type { string }
|
|
1467
|
+
* @memberof WsSessionToolResultOutput
|
|
1468
|
+
*/
|
|
1469
|
+
status: string;
|
|
1470
|
+
};
|
|
1927
1471
|
|
|
1928
|
-
export function
|
|
1472
|
+
export function decodeWsSessionToolResultOutput(
|
|
1473
|
+
rawInput: unknown
|
|
1474
|
+
): WsSessionToolResultOutput | null {
|
|
1929
1475
|
if (isJSON(rawInput)) {
|
|
1930
|
-
const decodedType = decodeString(rawInput
|
|
1931
|
-
const
|
|
1476
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1477
|
+
const decodedId = decodeString(rawInput['id']);
|
|
1478
|
+
const decodedOutput = decodeString(rawInput['output']);
|
|
1479
|
+
const decodedIsError = decodeBoolean(rawInput['isError']);
|
|
1480
|
+
const decodedStatus = decodeString(rawInput['status']);
|
|
1932
1481
|
|
|
1933
1482
|
if (
|
|
1934
|
-
decodedType === null
|
|
1483
|
+
decodedType === null ||
|
|
1484
|
+
decodedId === null ||
|
|
1485
|
+
decodedOutput === null ||
|
|
1486
|
+
decodedIsError === null ||
|
|
1487
|
+
decodedStatus === null
|
|
1935
1488
|
) {
|
|
1936
1489
|
return null;
|
|
1937
1490
|
}
|
|
1938
1491
|
|
|
1939
1492
|
return {
|
|
1940
|
-
|
|
1941
|
-
|
|
1493
|
+
type: decodedType,
|
|
1494
|
+
id: decodedId,
|
|
1495
|
+
output: decodedOutput,
|
|
1496
|
+
isError: decodedIsError,
|
|
1497
|
+
status: decodedStatus,
|
|
1942
1498
|
};
|
|
1943
1499
|
}
|
|
1944
1500
|
return null;
|
|
1945
1501
|
}
|
|
1946
1502
|
|
|
1947
|
-
|
|
1503
|
+
/**
|
|
1504
|
+
* @type { WsSessionThinkingOutput }
|
|
1505
|
+
* @description AI thinking/reasoning block (extended thinking)
|
|
1506
|
+
*/
|
|
1507
|
+
export type WsSessionThinkingOutput = {
|
|
1508
|
+
/**
|
|
1509
|
+
* @type { string }
|
|
1510
|
+
* @memberof WsSessionThinkingOutput
|
|
1511
|
+
*/
|
|
1512
|
+
type: string;
|
|
1513
|
+
/**
|
|
1514
|
+
* @description Thinking content text
|
|
1515
|
+
* @type { string }
|
|
1516
|
+
* @memberof WsSessionThinkingOutput
|
|
1517
|
+
*/
|
|
1518
|
+
text: string;
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
export function decodeWsSessionThinkingOutput(rawInput: unknown): WsSessionThinkingOutput | null {
|
|
1948
1522
|
if (isJSON(rawInput)) {
|
|
1949
|
-
const
|
|
1950
|
-
const
|
|
1951
|
-
const decodedArgs = decodeArray(rawInput.args, decodeString);
|
|
1952
|
-
const decodedCwd = decodeString(rawInput.cwd);
|
|
1953
|
-
const decodedPid = decodeNumber(rawInput.pid);
|
|
1954
|
-
const decodedCreatedAt = decodeString(rawInput.createdAt);
|
|
1955
|
-
const decodedExitedAt = decodeString(rawInput.exitedAt);
|
|
1956
|
-
const decodedStatus = decodeTerminalStatus(rawInput.status);
|
|
1957
|
-
const decodedExitCode = decodeNumber(rawInput.exitCode);
|
|
1958
|
-
const decodedHolderPid = decodeNumber(rawInput.holderPid);
|
|
1959
|
-
const decodedSocketPath = decodeString(rawInput.socketPath);
|
|
1960
|
-
const decodedIsActive = decodeBoolean(rawInput.isActive);
|
|
1961
|
-
const decodedCurrentCwd = decodeString(rawInput.currentCwd);
|
|
1523
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1524
|
+
const decodedText = decodeString(rawInput['text']);
|
|
1962
1525
|
|
|
1963
|
-
if (
|
|
1964
|
-
decodedId === null ||
|
|
1965
|
-
decodedCommand === null ||
|
|
1966
|
-
decodedArgs === null ||
|
|
1967
|
-
decodedCwd === null ||
|
|
1968
|
-
decodedPid === null ||
|
|
1969
|
-
decodedCreatedAt === null ||
|
|
1970
|
-
decodedStatus === null
|
|
1971
|
-
) {
|
|
1526
|
+
if (decodedType === null || decodedText === null) {
|
|
1972
1527
|
return null;
|
|
1973
1528
|
}
|
|
1974
1529
|
|
|
1975
1530
|
return {
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
createdAt: decodedCreatedAt,
|
|
1979
|
-
currentCwd: decodedCurrentCwd,
|
|
1980
|
-
cwd: decodedCwd,
|
|
1981
|
-
exitCode: decodedExitCode,
|
|
1982
|
-
exitedAt: decodedExitedAt,
|
|
1983
|
-
holderPid: decodedHolderPid,
|
|
1984
|
-
id: decodedId,
|
|
1985
|
-
isActive: decodedIsActive,
|
|
1986
|
-
pid: decodedPid,
|
|
1987
|
-
socketPath: decodedSocketPath,
|
|
1988
|
-
status: decodedStatus
|
|
1531
|
+
type: decodedType,
|
|
1532
|
+
text: decodedText,
|
|
1989
1533
|
};
|
|
1990
1534
|
}
|
|
1991
1535
|
return null;
|
|
1992
1536
|
}
|
|
1993
1537
|
|
|
1538
|
+
/**
|
|
1539
|
+
* @type { WsSessionEndOutput }
|
|
1540
|
+
* @description Session has ended (process exited or session file closed)
|
|
1541
|
+
*/
|
|
1542
|
+
export type WsSessionEndOutput = {
|
|
1543
|
+
/**
|
|
1544
|
+
* @type { string }
|
|
1545
|
+
* @memberof WsSessionEndOutput
|
|
1546
|
+
*/
|
|
1547
|
+
type: string;
|
|
1548
|
+
};
|
|
1994
1549
|
|
|
1995
|
-
|
|
1996
|
-
export function decodeRoleEnum(rawInput: unknown): null | RoleEnum {
|
|
1997
|
-
switch (rawInput) {
|
|
1998
|
-
case 'assistant':
|
|
1999
|
-
case 'user':
|
|
2000
|
-
return rawInput;
|
|
2001
|
-
}
|
|
2002
|
-
return null;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
export function decodeTerminalListResponse(rawInput: unknown): null | TerminalListResponse {
|
|
1550
|
+
export function decodeWsSessionEndOutput(rawInput: unknown): WsSessionEndOutput | null {
|
|
2006
1551
|
if (isJSON(rawInput)) {
|
|
2007
|
-
const
|
|
2008
|
-
const decodedCount = decodeNumber(rawInput.count);
|
|
1552
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2009
1553
|
|
|
2010
|
-
if (
|
|
2011
|
-
decodedTerminals === null ||
|
|
2012
|
-
decodedCount === null
|
|
2013
|
-
) {
|
|
1554
|
+
if (decodedType === null) {
|
|
2014
1555
|
return null;
|
|
2015
1556
|
}
|
|
2016
1557
|
|
|
2017
1558
|
return {
|
|
2018
|
-
|
|
2019
|
-
terminals: decodedTerminals
|
|
1559
|
+
type: decodedType,
|
|
2020
1560
|
};
|
|
2021
1561
|
}
|
|
2022
1562
|
return null;
|
|
2023
1563
|
}
|
|
2024
1564
|
|
|
1565
|
+
/**
|
|
1566
|
+
* @type { WsSessionErrorOutput }
|
|
1567
|
+
* @description Error message from the session handler
|
|
1568
|
+
*/
|
|
1569
|
+
export type WsSessionErrorOutput = {
|
|
1570
|
+
/**
|
|
1571
|
+
* @type { string }
|
|
1572
|
+
* @memberof WsSessionErrorOutput
|
|
1573
|
+
*/
|
|
1574
|
+
type: string;
|
|
1575
|
+
/**
|
|
1576
|
+
* @description Human-readable error message
|
|
1577
|
+
* @type { string }
|
|
1578
|
+
* @memberof WsSessionErrorOutput
|
|
1579
|
+
*/
|
|
1580
|
+
message: string;
|
|
1581
|
+
};
|
|
2025
1582
|
|
|
2026
|
-
|
|
2027
|
-
export function decodeTerminalRecord(rawInput: unknown): null | TerminalRecord {
|
|
1583
|
+
export function decodeWsSessionErrorOutput(rawInput: unknown): WsSessionErrorOutput | null {
|
|
2028
1584
|
if (isJSON(rawInput)) {
|
|
2029
|
-
const
|
|
2030
|
-
const
|
|
2031
|
-
const decodedArgs = decodeString(rawInput.args);
|
|
2032
|
-
const decodedCwd = decodeString(rawInput.cwd);
|
|
2033
|
-
const decodedCols = decodeNumber(rawInput.cols);
|
|
2034
|
-
const decodedRows = decodeNumber(rawInput.rows);
|
|
2035
|
-
const decodedPid = decodeNumber(rawInput.pid);
|
|
2036
|
-
const decodedHolderPid = decodeNumber(rawInput.holderPid);
|
|
2037
|
-
const decodedSocketPath = decodeString(rawInput.socketPath);
|
|
2038
|
-
const decodedSessionFile = decodeString(rawInput.sessionFile);
|
|
2039
|
-
const decodedOpencodeSessionId = decodeString(rawInput.opencodeSessionId);
|
|
2040
|
-
const decodedStatus = decodeTerminalStatus(rawInput.status);
|
|
2041
|
-
const decodedExitCode = decodeNumber(rawInput.exitCode);
|
|
2042
|
-
const decodedCreatedAt = decodeString(rawInput.createdAt);
|
|
2043
|
-
const decodedExitedAt = decodeString(rawInput.exitedAt);
|
|
1585
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1586
|
+
const decodedMessage = decodeString(rawInput['message']);
|
|
2044
1587
|
|
|
2045
|
-
if (
|
|
2046
|
-
decodedId === null ||
|
|
2047
|
-
decodedCommand === null ||
|
|
2048
|
-
decodedArgs === null ||
|
|
2049
|
-
decodedCwd === null ||
|
|
2050
|
-
decodedCols === null ||
|
|
2051
|
-
decodedRows === null ||
|
|
2052
|
-
decodedStatus === null ||
|
|
2053
|
-
decodedCreatedAt === null
|
|
2054
|
-
) {
|
|
1588
|
+
if (decodedType === null || decodedMessage === null) {
|
|
2055
1589
|
return null;
|
|
2056
1590
|
}
|
|
2057
1591
|
|
|
2058
1592
|
return {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
command: decodedCommand,
|
|
2062
|
-
createdAt: decodedCreatedAt,
|
|
2063
|
-
cwd: decodedCwd,
|
|
2064
|
-
exitCode: decodedExitCode,
|
|
2065
|
-
exitedAt: decodedExitedAt,
|
|
2066
|
-
holderPid: decodedHolderPid,
|
|
2067
|
-
id: decodedId,
|
|
2068
|
-
opencodeSessionId: decodedOpencodeSessionId,
|
|
2069
|
-
pid: decodedPid,
|
|
2070
|
-
rows: decodedRows,
|
|
2071
|
-
sessionFile: decodedSessionFile,
|
|
2072
|
-
socketPath: decodedSocketPath,
|
|
2073
|
-
status: decodedStatus
|
|
1593
|
+
type: decodedType,
|
|
1594
|
+
message: decodedMessage,
|
|
2074
1595
|
};
|
|
2075
1596
|
}
|
|
2076
1597
|
return null;
|
|
2077
1598
|
}
|
|
2078
1599
|
|
|
2079
|
-
export
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
1600
|
+
export type WsSessionOutput =
|
|
1601
|
+
| CWsSessionOutputWsSessionHistoryOutput
|
|
1602
|
+
| CWsSessionOutputWsSessionMessageOutput
|
|
1603
|
+
| CWsSessionOutputWsSessionToolUseOutput
|
|
1604
|
+
| CWsSessionOutputWsSessionToolResultOutput
|
|
1605
|
+
| CWsSessionOutputWsSessionThinkingOutput
|
|
1606
|
+
| CWsSessionOutputWsSessionEndOutput
|
|
1607
|
+
| CWsSessionOutputWsSessionErrorOutput;
|
|
1608
|
+
|
|
1609
|
+
export function decodeWsSessionOutput(rawInput: unknown): WsSessionOutput | null {
|
|
1610
|
+
const result: WsSessionOutput | null =
|
|
1611
|
+
decodeCWsSessionOutputWsSessionHistoryOutput(rawInput) ??
|
|
1612
|
+
decodeCWsSessionOutputWsSessionMessageOutput(rawInput) ??
|
|
1613
|
+
decodeCWsSessionOutputWsSessionToolUseOutput(rawInput) ??
|
|
1614
|
+
decodeCWsSessionOutputWsSessionToolResultOutput(rawInput) ??
|
|
1615
|
+
decodeCWsSessionOutputWsSessionThinkingOutput(rawInput) ??
|
|
1616
|
+
decodeCWsSessionOutputWsSessionEndOutput(rawInput) ??
|
|
1617
|
+
decodeCWsSessionOutputWsSessionErrorOutput(rawInput);
|
|
2089
1618
|
|
|
1619
|
+
return result;
|
|
1620
|
+
}
|
|
2090
1621
|
|
|
2091
|
-
export
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
case 'running':
|
|
2096
|
-
return rawInput;
|
|
1622
|
+
export class CWsSessionOutputWsSessionHistoryOutput {
|
|
1623
|
+
data: WsSessionHistoryOutput;
|
|
1624
|
+
constructor(data: WsSessionHistoryOutput) {
|
|
1625
|
+
this.data = data;
|
|
2097
1626
|
}
|
|
2098
|
-
return null;
|
|
2099
1627
|
}
|
|
2100
1628
|
|
|
2101
|
-
export function
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
1629
|
+
export function decodeCWsSessionOutputWsSessionHistoryOutput(
|
|
1630
|
+
rawInput: unknown
|
|
1631
|
+
): CWsSessionOutputWsSessionHistoryOutput | null {
|
|
1632
|
+
const result = decodeWsSessionHistoryOutput(rawInput);
|
|
1633
|
+
if (result === null) {
|
|
1634
|
+
return null;
|
|
2106
1635
|
}
|
|
2107
|
-
return
|
|
1636
|
+
return new CWsSessionOutputWsSessionHistoryOutput(result);
|
|
2108
1637
|
}
|
|
2109
1638
|
|
|
1639
|
+
export class CWsSessionOutputWsSessionMessageOutput {
|
|
1640
|
+
data: WsSessionMessageOutput;
|
|
1641
|
+
constructor(data: WsSessionMessageOutput) {
|
|
1642
|
+
this.data = data;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
2110
1645
|
|
|
1646
|
+
export function decodeCWsSessionOutputWsSessionMessageOutput(
|
|
1647
|
+
rawInput: unknown
|
|
1648
|
+
): CWsSessionOutputWsSessionMessageOutput | null {
|
|
1649
|
+
const result = decodeWsSessionMessageOutput(rawInput);
|
|
1650
|
+
if (result === null) {
|
|
1651
|
+
return null;
|
|
1652
|
+
}
|
|
1653
|
+
return new CWsSessionOutputWsSessionMessageOutput(result);
|
|
1654
|
+
}
|
|
2111
1655
|
|
|
2112
|
-
export
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
decodeCWsEvent3(rawInput)
|
|
2119
|
-
??
|
|
2120
|
-
decodeCWsEvent4(rawInput)
|
|
2121
|
-
??
|
|
2122
|
-
decodeCWsEvent5(rawInput)
|
|
1656
|
+
export class CWsSessionOutputWsSessionToolUseOutput {
|
|
1657
|
+
data: WsSessionToolUseOutput;
|
|
1658
|
+
constructor(data: WsSessionToolUseOutput) {
|
|
1659
|
+
this.data = data;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
2123
1662
|
|
|
2124
|
-
|
|
2125
|
-
|
|
1663
|
+
export function decodeCWsSessionOutputWsSessionToolUseOutput(
|
|
1664
|
+
rawInput: unknown
|
|
1665
|
+
): CWsSessionOutputWsSessionToolUseOutput | null {
|
|
1666
|
+
const result = decodeWsSessionToolUseOutput(rawInput);
|
|
1667
|
+
if (result === null) {
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
return new CWsSessionOutputWsSessionToolUseOutput(result);
|
|
2126
1671
|
}
|
|
2127
1672
|
|
|
2128
|
-
export
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
1673
|
+
export class CWsSessionOutputWsSessionToolResultOutput {
|
|
1674
|
+
data: WsSessionToolResultOutput;
|
|
1675
|
+
constructor(data: WsSessionToolResultOutput) {
|
|
1676
|
+
this.data = data;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
2134
1679
|
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
1680
|
+
export function decodeCWsSessionOutputWsSessionToolResultOutput(
|
|
1681
|
+
rawInput: unknown
|
|
1682
|
+
): CWsSessionOutputWsSessionToolResultOutput | null {
|
|
1683
|
+
const result = decodeWsSessionToolResultOutput(rawInput);
|
|
1684
|
+
if (result === null) {
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
return new CWsSessionOutputWsSessionToolResultOutput(result);
|
|
1688
|
+
}
|
|
2143
1689
|
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
type: decodedType
|
|
2149
|
-
};
|
|
1690
|
+
export class CWsSessionOutputWsSessionThinkingOutput {
|
|
1691
|
+
data: WsSessionThinkingOutput;
|
|
1692
|
+
constructor(data: WsSessionThinkingOutput) {
|
|
1693
|
+
this.data = data;
|
|
2150
1694
|
}
|
|
2151
|
-
return null;
|
|
2152
1695
|
}
|
|
2153
1696
|
|
|
1697
|
+
export function decodeCWsSessionOutputWsSessionThinkingOutput(
|
|
1698
|
+
rawInput: unknown
|
|
1699
|
+
): CWsSessionOutputWsSessionThinkingOutput | null {
|
|
1700
|
+
const result = decodeWsSessionThinkingOutput(rawInput);
|
|
1701
|
+
if (result === null) {
|
|
1702
|
+
return null;
|
|
1703
|
+
}
|
|
1704
|
+
return new CWsSessionOutputWsSessionThinkingOutput(result);
|
|
1705
|
+
}
|
|
2154
1706
|
|
|
1707
|
+
export class CWsSessionOutputWsSessionEndOutput {
|
|
1708
|
+
data: WsSessionEndOutput;
|
|
1709
|
+
constructor(data: WsSessionEndOutput) {
|
|
1710
|
+
this.data = data;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
2155
1713
|
|
|
2156
|
-
export function
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
1714
|
+
export function decodeCWsSessionOutputWsSessionEndOutput(
|
|
1715
|
+
rawInput: unknown
|
|
1716
|
+
): CWsSessionOutputWsSessionEndOutput | null {
|
|
1717
|
+
const result = decodeWsSessionEndOutput(rawInput);
|
|
1718
|
+
if (result === null) {
|
|
1719
|
+
return null;
|
|
1720
|
+
}
|
|
1721
|
+
return new CWsSessionOutputWsSessionEndOutput(result);
|
|
1722
|
+
}
|
|
2161
1723
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
1724
|
+
export class CWsSessionOutputWsSessionErrorOutput {
|
|
1725
|
+
data: WsSessionErrorOutput;
|
|
1726
|
+
constructor(data: WsSessionErrorOutput) {
|
|
1727
|
+
this.data = data;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
2168
1730
|
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
1731
|
+
export function decodeCWsSessionOutputWsSessionErrorOutput(
|
|
1732
|
+
rawInput: unknown
|
|
1733
|
+
): CWsSessionOutputWsSessionErrorOutput | null {
|
|
1734
|
+
const result = decodeWsSessionErrorOutput(rawInput);
|
|
1735
|
+
if (result === null) {
|
|
1736
|
+
return null;
|
|
2174
1737
|
}
|
|
2175
|
-
return
|
|
1738
|
+
return new CWsSessionOutputWsSessionErrorOutput(result);
|
|
2176
1739
|
}
|
|
2177
1740
|
|
|
2178
|
-
|
|
1741
|
+
/**
|
|
1742
|
+
* @type { WsSessionStartedEvent }
|
|
1743
|
+
* @description A new AI session has started
|
|
1744
|
+
*/
|
|
1745
|
+
export type WsSessionStartedEvent = {
|
|
1746
|
+
/**
|
|
1747
|
+
* @type { string }
|
|
1748
|
+
* @memberof WsSessionStartedEvent
|
|
1749
|
+
*/
|
|
1750
|
+
type: string;
|
|
1751
|
+
/**
|
|
1752
|
+
* @description Unique session identifier
|
|
1753
|
+
* @type { string }
|
|
1754
|
+
* @memberof WsSessionStartedEvent
|
|
1755
|
+
*/
|
|
1756
|
+
sessionId: string;
|
|
1757
|
+
/**
|
|
1758
|
+
* @description Project name or path
|
|
1759
|
+
* @type { string }
|
|
1760
|
+
* @memberof WsSessionStartedEvent
|
|
1761
|
+
*/
|
|
1762
|
+
project: string;
|
|
1763
|
+
/**
|
|
1764
|
+
* @description Source tool that started the session
|
|
1765
|
+
* @type { SessionSource }
|
|
1766
|
+
* @memberof WsSessionStartedEvent
|
|
1767
|
+
*/
|
|
1768
|
+
source: SessionSource;
|
|
1769
|
+
};
|
|
1770
|
+
|
|
1771
|
+
export function decodeWsSessionStartedEvent(rawInput: unknown): WsSessionStartedEvent | null {
|
|
2179
1772
|
if (isJSON(rawInput)) {
|
|
2180
|
-
const decodedType = decodeString(rawInput
|
|
2181
|
-
const
|
|
2182
|
-
const
|
|
2183
|
-
const
|
|
1773
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1774
|
+
const decodedSessionId = decodeString(rawInput['sessionId']);
|
|
1775
|
+
const decodedProject = decodeString(rawInput['project']);
|
|
1776
|
+
const decodedSource = decodeSessionSource(rawInput['source']);
|
|
2184
1777
|
|
|
2185
1778
|
if (
|
|
2186
1779
|
decodedType === null ||
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
1780
|
+
decodedSessionId === null ||
|
|
1781
|
+
decodedProject === null ||
|
|
1782
|
+
decodedSource === null
|
|
2190
1783
|
) {
|
|
2191
1784
|
return null;
|
|
2192
1785
|
}
|
|
2193
1786
|
|
|
2194
1787
|
return {
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
1788
|
+
type: decodedType,
|
|
1789
|
+
sessionId: decodedSessionId,
|
|
1790
|
+
project: decodedProject,
|
|
1791
|
+
source: decodedSource,
|
|
2199
1792
|
};
|
|
2200
1793
|
}
|
|
2201
1794
|
return null;
|
|
2202
1795
|
}
|
|
2203
1796
|
|
|
1797
|
+
/**
|
|
1798
|
+
* @type { WsSessionEndedEvent }
|
|
1799
|
+
* @description An AI session has ended
|
|
1800
|
+
*/
|
|
1801
|
+
export type WsSessionEndedEvent = {
|
|
1802
|
+
/**
|
|
1803
|
+
* @type { string }
|
|
1804
|
+
* @memberof WsSessionEndedEvent
|
|
1805
|
+
*/
|
|
1806
|
+
type: string;
|
|
1807
|
+
/**
|
|
1808
|
+
* @description Session identifier that ended
|
|
1809
|
+
* @type { string }
|
|
1810
|
+
* @memberof WsSessionEndedEvent
|
|
1811
|
+
*/
|
|
1812
|
+
sessionId: string;
|
|
1813
|
+
/**
|
|
1814
|
+
* @description Summary of what happened in the session
|
|
1815
|
+
* @type { string }
|
|
1816
|
+
* @memberof WsSessionEndedEvent
|
|
1817
|
+
*/
|
|
1818
|
+
summary: string;
|
|
1819
|
+
};
|
|
2204
1820
|
|
|
2205
|
-
export function
|
|
2206
|
-
if (isJSON(rawInput)) {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
return {
|
|
2210
|
-
...rawInput,
|
|
2211
|
-
};
|
|
2212
|
-
}
|
|
2213
|
-
return null;
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
export function decodeWsEvent4(rawInput: unknown): null | WsEvent4 {
|
|
1821
|
+
export function decodeWsSessionEndedEvent(rawInput: unknown): WsSessionEndedEvent | null {
|
|
2217
1822
|
if (isJSON(rawInput)) {
|
|
2218
|
-
const decodedType = decodeString(rawInput
|
|
2219
|
-
const
|
|
2220
|
-
const
|
|
1823
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1824
|
+
const decodedSessionId = decodeString(rawInput['sessionId']);
|
|
1825
|
+
const decodedSummary = decodeString(rawInput['summary']);
|
|
2221
1826
|
|
|
2222
|
-
if (
|
|
2223
|
-
decodedType === null ||
|
|
2224
|
-
decodedTerminalId === null ||
|
|
2225
|
-
decodedCommand === null
|
|
2226
|
-
) {
|
|
1827
|
+
if (decodedType === null || decodedSessionId === null || decodedSummary === null) {
|
|
2227
1828
|
return null;
|
|
2228
1829
|
}
|
|
2229
1830
|
|
|
2230
1831
|
return {
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
1832
|
+
type: decodedType,
|
|
1833
|
+
sessionId: decodedSessionId,
|
|
1834
|
+
summary: decodedSummary,
|
|
2234
1835
|
};
|
|
2235
1836
|
}
|
|
2236
1837
|
return null;
|
|
2237
1838
|
}
|
|
2238
1839
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
1840
|
+
/**
|
|
1841
|
+
* @type { WsPermissionRequestedEvent }
|
|
1842
|
+
* @description A permission request is awaiting approval
|
|
1843
|
+
*/
|
|
1844
|
+
export type WsPermissionRequestedEvent = {
|
|
1845
|
+
/**
|
|
1846
|
+
* @type { string }
|
|
1847
|
+
* @memberof WsPermissionRequestedEvent
|
|
1848
|
+
*/
|
|
1849
|
+
type: string;
|
|
1850
|
+
/**
|
|
1851
|
+
* @description Unique request identifier for the permission flow
|
|
1852
|
+
* @type { string }
|
|
1853
|
+
* @memberof WsPermissionRequestedEvent
|
|
1854
|
+
*/
|
|
1855
|
+
requestId: string;
|
|
1856
|
+
/**
|
|
1857
|
+
* @description Tool requesting permission (e.g. "Bash", "Edit")
|
|
1858
|
+
* @type { string }
|
|
1859
|
+
* @memberof WsPermissionRequestedEvent
|
|
1860
|
+
*/
|
|
1861
|
+
tool: string;
|
|
1862
|
+
/**
|
|
1863
|
+
* @description Tool input that requires approval
|
|
1864
|
+
* @type { WsPermissionRequestedEventInput }
|
|
1865
|
+
* @memberof WsPermissionRequestedEvent
|
|
1866
|
+
*/
|
|
1867
|
+
input: WsPermissionRequestedEventInput;
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
export function decodeWsPermissionRequestedEvent(
|
|
1871
|
+
rawInput: unknown
|
|
1872
|
+
): WsPermissionRequestedEvent | null {
|
|
2243
1873
|
if (isJSON(rawInput)) {
|
|
2244
|
-
const decodedType = decodeString(rawInput
|
|
2245
|
-
const
|
|
2246
|
-
const
|
|
1874
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1875
|
+
const decodedRequestId = decodeString(rawInput['requestId']);
|
|
1876
|
+
const decodedTool = decodeString(rawInput['tool']);
|
|
1877
|
+
const decodedInput = decodeWsPermissionRequestedEventInput(rawInput['input']);
|
|
2247
1878
|
|
|
2248
1879
|
if (
|
|
2249
1880
|
decodedType === null ||
|
|
2250
|
-
|
|
2251
|
-
|
|
1881
|
+
decodedRequestId === null ||
|
|
1882
|
+
decodedTool === null ||
|
|
1883
|
+
decodedInput === null
|
|
2252
1884
|
) {
|
|
2253
1885
|
return null;
|
|
2254
1886
|
}
|
|
2255
1887
|
|
|
2256
1888
|
return {
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
1889
|
+
type: decodedType,
|
|
1890
|
+
requestId: decodedRequestId,
|
|
1891
|
+
tool: decodedTool,
|
|
1892
|
+
input: decodedInput,
|
|
2260
1893
|
};
|
|
2261
1894
|
}
|
|
2262
1895
|
return null;
|
|
2263
1896
|
}
|
|
2264
1897
|
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
??
|
|
2271
|
-
decodeCWsSessionMessage3(rawInput)
|
|
2272
|
-
|
|
2273
|
-
;
|
|
2274
|
-
return result;
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
|
|
1898
|
+
/**
|
|
1899
|
+
* @type { WsPermissionRequestedEventInput }
|
|
1900
|
+
* @description Tool input that requires approval
|
|
1901
|
+
*/
|
|
1902
|
+
export type WsPermissionRequestedEventInput = Record<string, unknown>;
|
|
2278
1903
|
|
|
2279
|
-
export function
|
|
1904
|
+
export function decodeWsPermissionRequestedEventInput(
|
|
1905
|
+
rawInput: unknown
|
|
1906
|
+
): WsPermissionRequestedEventInput | null {
|
|
2280
1907
|
if (isJSON(rawInput)) {
|
|
2281
|
-
const decodedType = decodeString(rawInput.type);
|
|
2282
|
-
const decodedSessionId = decodeString(rawInput.sessionId);
|
|
2283
|
-
|
|
2284
|
-
if (
|
|
2285
|
-
decodedType === null ||
|
|
2286
|
-
decodedSessionId === null
|
|
2287
|
-
) {
|
|
2288
|
-
return null;
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
1908
|
return {
|
|
2292
|
-
|
|
2293
|
-
type: decodedType
|
|
1909
|
+
...rawInput,
|
|
2294
1910
|
};
|
|
2295
1911
|
}
|
|
2296
1912
|
return null;
|
|
2297
1913
|
}
|
|
2298
1914
|
|
|
2299
|
-
|
|
1915
|
+
/**
|
|
1916
|
+
* @type { WsPermissionResolvedEvent }
|
|
1917
|
+
* @description A permission request has been resolved
|
|
1918
|
+
*/
|
|
1919
|
+
export type WsPermissionResolvedEvent = {
|
|
1920
|
+
/**
|
|
1921
|
+
* @type { string }
|
|
1922
|
+
* @memberof WsPermissionResolvedEvent
|
|
1923
|
+
*/
|
|
1924
|
+
type: string;
|
|
1925
|
+
/**
|
|
1926
|
+
* @description Request identifier that was resolved
|
|
1927
|
+
* @type { string }
|
|
1928
|
+
* @memberof WsPermissionResolvedEvent
|
|
1929
|
+
*/
|
|
1930
|
+
requestId: string;
|
|
1931
|
+
/**
|
|
1932
|
+
* @description Whether the permission was allowed or denied
|
|
1933
|
+
* @type { PermissionDecision }
|
|
1934
|
+
* @memberof WsPermissionResolvedEvent
|
|
1935
|
+
*/
|
|
1936
|
+
decision: PermissionDecision;
|
|
1937
|
+
};
|
|
1938
|
+
|
|
1939
|
+
export function decodeWsPermissionResolvedEvent(
|
|
1940
|
+
rawInput: unknown
|
|
1941
|
+
): WsPermissionResolvedEvent | null {
|
|
2300
1942
|
if (isJSON(rawInput)) {
|
|
2301
|
-
const decodedType = decodeString(rawInput
|
|
2302
|
-
const
|
|
1943
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1944
|
+
const decodedRequestId = decodeString(rawInput['requestId']);
|
|
1945
|
+
const decodedDecision = decodePermissionDecision(rawInput['decision']);
|
|
2303
1946
|
|
|
2304
|
-
if (
|
|
2305
|
-
decodedType === null ||
|
|
2306
|
-
decodedText === null
|
|
2307
|
-
) {
|
|
1947
|
+
if (decodedType === null || decodedRequestId === null || decodedDecision === null) {
|
|
2308
1948
|
return null;
|
|
2309
1949
|
}
|
|
2310
1950
|
|
|
2311
1951
|
return {
|
|
2312
|
-
|
|
2313
|
-
|
|
1952
|
+
type: decodedType,
|
|
1953
|
+
requestId: decodedRequestId,
|
|
1954
|
+
decision: decodedDecision,
|
|
2314
1955
|
};
|
|
2315
1956
|
}
|
|
2316
1957
|
return null;
|
|
2317
1958
|
}
|
|
2318
1959
|
|
|
1960
|
+
/**
|
|
1961
|
+
* @type { WsTerminalCreatedEvent }
|
|
1962
|
+
* @description A new managed terminal has been created
|
|
1963
|
+
*/
|
|
1964
|
+
export type WsTerminalCreatedEvent = {
|
|
1965
|
+
/**
|
|
1966
|
+
* @type { string }
|
|
1967
|
+
* @memberof WsTerminalCreatedEvent
|
|
1968
|
+
*/
|
|
1969
|
+
type: string;
|
|
1970
|
+
/**
|
|
1971
|
+
* @description Unique terminal identifier
|
|
1972
|
+
* @type { string }
|
|
1973
|
+
* @memberof WsTerminalCreatedEvent
|
|
1974
|
+
*/
|
|
1975
|
+
terminalId: string;
|
|
1976
|
+
/**
|
|
1977
|
+
* @description Command that was launched
|
|
1978
|
+
* @type { string }
|
|
1979
|
+
* @memberof WsTerminalCreatedEvent
|
|
1980
|
+
*/
|
|
1981
|
+
command: string;
|
|
1982
|
+
};
|
|
2319
1983
|
|
|
2320
|
-
|
|
2321
|
-
export function decodeWsSessionMessage3(rawInput: unknown): null | WsSessionMessage3 {
|
|
1984
|
+
export function decodeWsTerminalCreatedEvent(rawInput: unknown): WsTerminalCreatedEvent | null {
|
|
2322
1985
|
if (isJSON(rawInput)) {
|
|
2323
|
-
const decodedType = decodeString(rawInput
|
|
1986
|
+
const decodedType = decodeString(rawInput['type']);
|
|
1987
|
+
const decodedTerminalId = decodeString(rawInput['terminalId']);
|
|
1988
|
+
const decodedCommand = decodeString(rawInput['command']);
|
|
2324
1989
|
|
|
2325
|
-
if (
|
|
2326
|
-
decodedType === null
|
|
2327
|
-
) {
|
|
1990
|
+
if (decodedType === null || decodedTerminalId === null || decodedCommand === null) {
|
|
2328
1991
|
return null;
|
|
2329
1992
|
}
|
|
2330
1993
|
|
|
2331
1994
|
return {
|
|
2332
|
-
type: decodedType
|
|
1995
|
+
type: decodedType,
|
|
1996
|
+
terminalId: decodedTerminalId,
|
|
1997
|
+
command: decodedCommand,
|
|
2333
1998
|
};
|
|
2334
1999
|
}
|
|
2335
2000
|
return null;
|
|
2336
2001
|
}
|
|
2337
2002
|
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2003
|
+
/**
|
|
2004
|
+
* @type { WsTerminalExitedEvent }
|
|
2005
|
+
* @description A managed terminal process has exited
|
|
2006
|
+
*/
|
|
2007
|
+
export type WsTerminalExitedEvent = {
|
|
2008
|
+
/**
|
|
2009
|
+
* @type { string }
|
|
2010
|
+
* @memberof WsTerminalExitedEvent
|
|
2011
|
+
*/
|
|
2012
|
+
type: string;
|
|
2013
|
+
/**
|
|
2014
|
+
* @description Terminal identifier that exited
|
|
2015
|
+
* @type { string }
|
|
2016
|
+
* @memberof WsTerminalExitedEvent
|
|
2017
|
+
*/
|
|
2018
|
+
terminalId: string;
|
|
2019
|
+
/**
|
|
2020
|
+
* @description Process exit code, or null if terminated by signal
|
|
2021
|
+
* @type { number }
|
|
2022
|
+
* @memberof WsTerminalExitedEvent
|
|
2023
|
+
*/
|
|
2024
|
+
code: number | null;
|
|
2025
|
+
};
|
|
2357
2026
|
|
|
2358
|
-
export function
|
|
2027
|
+
export function decodeWsTerminalExitedEvent(rawInput: unknown): WsTerminalExitedEvent | null {
|
|
2359
2028
|
if (isJSON(rawInput)) {
|
|
2360
|
-
const decodedType = decodeString(rawInput
|
|
2361
|
-
const
|
|
2029
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2030
|
+
const decodedTerminalId = decodeString(rawInput['terminalId']);
|
|
2031
|
+
const decodedCode = decodeNumber(rawInput['code']);
|
|
2362
2032
|
|
|
2363
|
-
if (
|
|
2364
|
-
decodedType === null ||
|
|
2365
|
-
decodedMessages === null
|
|
2366
|
-
) {
|
|
2033
|
+
if (decodedType === null || decodedTerminalId === null) {
|
|
2367
2034
|
return null;
|
|
2368
2035
|
}
|
|
2369
2036
|
|
|
2370
2037
|
return {
|
|
2371
|
-
|
|
2372
|
-
|
|
2038
|
+
type: decodedType,
|
|
2039
|
+
terminalId: decodedTerminalId,
|
|
2040
|
+
code: decodedCode,
|
|
2373
2041
|
};
|
|
2374
2042
|
}
|
|
2375
2043
|
return null;
|
|
2376
2044
|
}
|
|
2377
2045
|
|
|
2378
|
-
export
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2046
|
+
export type WsEvent =
|
|
2047
|
+
| CWsEventWsSessionStartedEvent
|
|
2048
|
+
| CWsEventWsSessionEndedEvent
|
|
2049
|
+
| CWsEventWsPermissionRequestedEvent
|
|
2050
|
+
| CWsEventWsPermissionResolvedEvent
|
|
2051
|
+
| CWsEventWsTerminalCreatedEvent
|
|
2052
|
+
| CWsEventWsTerminalExitedEvent;
|
|
2053
|
+
|
|
2054
|
+
export function decodeWsEvent(rawInput: unknown): WsEvent | null {
|
|
2055
|
+
const result: WsEvent | null =
|
|
2056
|
+
decodeCWsEventWsSessionStartedEvent(rawInput) ??
|
|
2057
|
+
decodeCWsEventWsSessionEndedEvent(rawInput) ??
|
|
2058
|
+
decodeCWsEventWsPermissionRequestedEvent(rawInput) ??
|
|
2059
|
+
decodeCWsEventWsPermissionResolvedEvent(rawInput) ??
|
|
2060
|
+
decodeCWsEventWsTerminalCreatedEvent(rawInput) ??
|
|
2061
|
+
decodeCWsEventWsTerminalExitedEvent(rawInput);
|
|
2384
2062
|
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
decodedRole === null ||
|
|
2388
|
-
decodedContent === null ||
|
|
2389
|
-
decodedTimestamp === null
|
|
2390
|
-
) {
|
|
2391
|
-
return null;
|
|
2392
|
-
}
|
|
2063
|
+
return result;
|
|
2064
|
+
}
|
|
2393
2065
|
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
type: decodedType
|
|
2399
|
-
};
|
|
2066
|
+
export class CWsEventWsSessionStartedEvent {
|
|
2067
|
+
data: WsSessionStartedEvent;
|
|
2068
|
+
constructor(data: WsSessionStartedEvent) {
|
|
2069
|
+
this.data = data;
|
|
2400
2070
|
}
|
|
2401
|
-
return null;
|
|
2402
2071
|
}
|
|
2403
2072
|
|
|
2073
|
+
export function decodeCWsEventWsSessionStartedEvent(
|
|
2074
|
+
rawInput: unknown
|
|
2075
|
+
): CWsEventWsSessionStartedEvent | null {
|
|
2076
|
+
const result = decodeWsSessionStartedEvent(rawInput);
|
|
2077
|
+
if (result === null) {
|
|
2078
|
+
return null;
|
|
2079
|
+
}
|
|
2080
|
+
return new CWsEventWsSessionStartedEvent(result);
|
|
2081
|
+
}
|
|
2404
2082
|
|
|
2083
|
+
export class CWsEventWsSessionEndedEvent {
|
|
2084
|
+
data: WsSessionEndedEvent;
|
|
2085
|
+
constructor(data: WsSessionEndedEvent) {
|
|
2086
|
+
this.data = data;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2405
2089
|
|
|
2406
|
-
export function
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2090
|
+
export function decodeCWsEventWsSessionEndedEvent(
|
|
2091
|
+
rawInput: unknown
|
|
2092
|
+
): CWsEventWsSessionEndedEvent | null {
|
|
2093
|
+
const result = decodeWsSessionEndedEvent(rawInput);
|
|
2094
|
+
if (result === null) {
|
|
2095
|
+
return null;
|
|
2096
|
+
}
|
|
2097
|
+
return new CWsEventWsSessionEndedEvent(result);
|
|
2098
|
+
}
|
|
2412
2099
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
return null;
|
|
2420
|
-
}
|
|
2100
|
+
export class CWsEventWsPermissionRequestedEvent {
|
|
2101
|
+
data: WsPermissionRequestedEvent;
|
|
2102
|
+
constructor(data: WsPermissionRequestedEvent) {
|
|
2103
|
+
this.data = data;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2421
2106
|
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2107
|
+
export function decodeCWsEventWsPermissionRequestedEvent(
|
|
2108
|
+
rawInput: unknown
|
|
2109
|
+
): CWsEventWsPermissionRequestedEvent | null {
|
|
2110
|
+
const result = decodeWsPermissionRequestedEvent(rawInput);
|
|
2111
|
+
if (result === null) {
|
|
2112
|
+
return null;
|
|
2428
2113
|
}
|
|
2429
|
-
return
|
|
2114
|
+
return new CWsEventWsPermissionRequestedEvent(result);
|
|
2430
2115
|
}
|
|
2431
2116
|
|
|
2432
|
-
export
|
|
2433
|
-
|
|
2117
|
+
export class CWsEventWsPermissionResolvedEvent {
|
|
2118
|
+
data: WsPermissionResolvedEvent;
|
|
2119
|
+
constructor(data: WsPermissionResolvedEvent) {
|
|
2120
|
+
this.data = data;
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2434
2123
|
|
|
2124
|
+
export function decodeCWsEventWsPermissionResolvedEvent(
|
|
2125
|
+
rawInput: unknown
|
|
2126
|
+
): CWsEventWsPermissionResolvedEvent | null {
|
|
2127
|
+
const result = decodeWsPermissionResolvedEvent(rawInput);
|
|
2128
|
+
if (result === null) {
|
|
2129
|
+
return null;
|
|
2130
|
+
}
|
|
2131
|
+
return new CWsEventWsPermissionResolvedEvent(result);
|
|
2132
|
+
}
|
|
2435
2133
|
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2134
|
+
export class CWsEventWsTerminalCreatedEvent {
|
|
2135
|
+
data: WsTerminalCreatedEvent;
|
|
2136
|
+
constructor(data: WsTerminalCreatedEvent) {
|
|
2137
|
+
this.data = data;
|
|
2439
2138
|
}
|
|
2440
|
-
return null;
|
|
2441
2139
|
}
|
|
2442
2140
|
|
|
2141
|
+
export function decodeCWsEventWsTerminalCreatedEvent(
|
|
2142
|
+
rawInput: unknown
|
|
2143
|
+
): CWsEventWsTerminalCreatedEvent | null {
|
|
2144
|
+
const result = decodeWsTerminalCreatedEvent(rawInput);
|
|
2145
|
+
if (result === null) {
|
|
2146
|
+
return null;
|
|
2147
|
+
}
|
|
2148
|
+
return new CWsEventWsTerminalCreatedEvent(result);
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
export class CWsEventWsTerminalExitedEvent {
|
|
2152
|
+
data: WsTerminalExitedEvent;
|
|
2153
|
+
constructor(data: WsTerminalExitedEvent) {
|
|
2154
|
+
this.data = data;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2443
2157
|
|
|
2158
|
+
export function decodeCWsEventWsTerminalExitedEvent(
|
|
2159
|
+
rawInput: unknown
|
|
2160
|
+
): CWsEventWsTerminalExitedEvent | null {
|
|
2161
|
+
const result = decodeWsTerminalExitedEvent(rawInput);
|
|
2162
|
+
if (result === null) {
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
return new CWsEventWsTerminalExitedEvent(result);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* @type { TerminalRecord }
|
|
2170
|
+
* @description Persisted terminal metadata stored in SQLite for recovery across server restarts
|
|
2171
|
+
*/
|
|
2172
|
+
export type TerminalRecord = {
|
|
2173
|
+
/**
|
|
2174
|
+
* @description Unique terminal identifier
|
|
2175
|
+
* @type { string }
|
|
2176
|
+
* @memberof TerminalRecord
|
|
2177
|
+
*/
|
|
2178
|
+
id: string;
|
|
2179
|
+
/**
|
|
2180
|
+
* @description The command that was launched
|
|
2181
|
+
* @type { string }
|
|
2182
|
+
* @memberof TerminalRecord
|
|
2183
|
+
*/
|
|
2184
|
+
command: string;
|
|
2185
|
+
/**
|
|
2186
|
+
* @description JSON-encoded array of command arguments
|
|
2187
|
+
* @type { string }
|
|
2188
|
+
* @memberof TerminalRecord
|
|
2189
|
+
*/
|
|
2190
|
+
args: string;
|
|
2191
|
+
/**
|
|
2192
|
+
* @description Working directory the terminal was launched in
|
|
2193
|
+
* @type { string }
|
|
2194
|
+
* @memberof TerminalRecord
|
|
2195
|
+
*/
|
|
2196
|
+
cwd: string;
|
|
2197
|
+
/**
|
|
2198
|
+
* @description Terminal width in columns
|
|
2199
|
+
* @type { number }
|
|
2200
|
+
* @memberof TerminalRecord
|
|
2201
|
+
*/
|
|
2202
|
+
cols: number;
|
|
2203
|
+
/**
|
|
2204
|
+
* @description Terminal height in rows
|
|
2205
|
+
* @type { number }
|
|
2206
|
+
* @memberof TerminalRecord
|
|
2207
|
+
*/
|
|
2208
|
+
rows: number;
|
|
2209
|
+
/**
|
|
2210
|
+
* @description PTY child process ID
|
|
2211
|
+
* @type { number }
|
|
2212
|
+
* @memberof TerminalRecord
|
|
2213
|
+
*/
|
|
2214
|
+
pid: number | null;
|
|
2215
|
+
/**
|
|
2216
|
+
* @description Holder process ID
|
|
2217
|
+
* @type { number }
|
|
2218
|
+
* @memberof TerminalRecord
|
|
2219
|
+
*/
|
|
2220
|
+
holderPid: number | null;
|
|
2221
|
+
/**
|
|
2222
|
+
* @description Unix domain socket path for holder communication
|
|
2223
|
+
* @type { string }
|
|
2224
|
+
* @memberof TerminalRecord
|
|
2225
|
+
*/
|
|
2226
|
+
socketPath: string | null;
|
|
2227
|
+
/**
|
|
2228
|
+
* @description Claude Code JSONL session file path
|
|
2229
|
+
* @type { string }
|
|
2230
|
+
* @memberof TerminalRecord
|
|
2231
|
+
*/
|
|
2232
|
+
sessionFile: string | null;
|
|
2233
|
+
/**
|
|
2234
|
+
* @description OpenCode SQLite session ID
|
|
2235
|
+
* @type { string }
|
|
2236
|
+
* @memberof TerminalRecord
|
|
2237
|
+
*/
|
|
2238
|
+
opencodeSessionId: string | null;
|
|
2239
|
+
/**
|
|
2240
|
+
* @description Terminal lifecycle status
|
|
2241
|
+
* @type { TerminalStatus }
|
|
2242
|
+
* @memberof TerminalRecord
|
|
2243
|
+
*/
|
|
2244
|
+
status: TerminalStatus;
|
|
2245
|
+
/**
|
|
2246
|
+
* @description Process exit code
|
|
2247
|
+
* @type { number }
|
|
2248
|
+
* @memberof TerminalRecord
|
|
2249
|
+
*/
|
|
2250
|
+
exitCode: number | null;
|
|
2251
|
+
/**
|
|
2252
|
+
* @description ISO 8601 timestamp when the terminal was created
|
|
2253
|
+
* @type { string }
|
|
2254
|
+
* @memberof TerminalRecord
|
|
2255
|
+
*/
|
|
2256
|
+
createdAt: string;
|
|
2257
|
+
/**
|
|
2258
|
+
* @description ISO 8601 timestamp when the process exited
|
|
2259
|
+
* @type { string }
|
|
2260
|
+
* @memberof TerminalRecord
|
|
2261
|
+
*/
|
|
2262
|
+
exitedAt: string | null;
|
|
2263
|
+
};
|
|
2444
2264
|
|
|
2445
|
-
export function
|
|
2265
|
+
export function decodeTerminalRecord(rawInput: unknown): TerminalRecord | null {
|
|
2446
2266
|
if (isJSON(rawInput)) {
|
|
2447
|
-
const
|
|
2448
|
-
const
|
|
2449
|
-
const
|
|
2450
|
-
const
|
|
2267
|
+
const decodedId = decodeString(rawInput['id']);
|
|
2268
|
+
const decodedCommand = decodeString(rawInput['command']);
|
|
2269
|
+
const decodedArgs = decodeString(rawInput['args']);
|
|
2270
|
+
const decodedCwd = decodeString(rawInput['cwd']);
|
|
2271
|
+
const decodedCols = decodeNumber(rawInput['cols']);
|
|
2272
|
+
const decodedRows = decodeNumber(rawInput['rows']);
|
|
2273
|
+
const decodedPid = decodeNumber(rawInput['pid']);
|
|
2274
|
+
const decodedHolderPid = decodeNumber(rawInput['holderPid']);
|
|
2275
|
+
const decodedSocketPath = decodeString(rawInput['socketPath']);
|
|
2276
|
+
const decodedSessionFile = decodeString(rawInput['sessionFile']);
|
|
2277
|
+
const decodedOpencodeSessionId = decodeString(rawInput['opencodeSessionId']);
|
|
2278
|
+
const decodedStatus = decodeTerminalStatus(rawInput['status']);
|
|
2279
|
+
const decodedExitCode = decodeNumber(rawInput['exitCode']);
|
|
2280
|
+
const decodedCreatedAt = decodeString(rawInput['createdAt']);
|
|
2281
|
+
const decodedExitedAt = decodeString(rawInput['exitedAt']);
|
|
2451
2282
|
|
|
2452
2283
|
if (
|
|
2453
|
-
decodedType === null ||
|
|
2454
2284
|
decodedId === null ||
|
|
2455
|
-
|
|
2456
|
-
|
|
2285
|
+
decodedCommand === null ||
|
|
2286
|
+
decodedArgs === null ||
|
|
2287
|
+
decodedCwd === null ||
|
|
2288
|
+
decodedCols === null ||
|
|
2289
|
+
decodedRows === null ||
|
|
2290
|
+
decodedStatus === null ||
|
|
2291
|
+
decodedCreatedAt === null
|
|
2457
2292
|
) {
|
|
2458
2293
|
return null;
|
|
2459
2294
|
}
|
|
2460
2295
|
|
|
2461
2296
|
return {
|
|
2462
2297
|
id: decodedId,
|
|
2463
|
-
|
|
2298
|
+
command: decodedCommand,
|
|
2299
|
+
args: decodedArgs,
|
|
2300
|
+
cwd: decodedCwd,
|
|
2301
|
+
cols: decodedCols,
|
|
2302
|
+
rows: decodedRows,
|
|
2303
|
+
pid: decodedPid,
|
|
2304
|
+
holderPid: decodedHolderPid,
|
|
2305
|
+
socketPath: decodedSocketPath,
|
|
2306
|
+
sessionFile: decodedSessionFile,
|
|
2307
|
+
opencodeSessionId: decodedOpencodeSessionId,
|
|
2464
2308
|
status: decodedStatus,
|
|
2465
|
-
|
|
2309
|
+
exitCode: decodedExitCode,
|
|
2310
|
+
createdAt: decodedCreatedAt,
|
|
2311
|
+
exitedAt: decodedExitedAt,
|
|
2466
2312
|
};
|
|
2467
2313
|
}
|
|
2468
2314
|
return null;
|
|
2469
2315
|
}
|
|
2470
2316
|
|
|
2471
|
-
|
|
2317
|
+
/**
|
|
2318
|
+
* @type { HolderInputMessage }
|
|
2319
|
+
* @description Write data to PTY stdin
|
|
2320
|
+
*/
|
|
2321
|
+
export type HolderInputMessage = {
|
|
2322
|
+
/**
|
|
2323
|
+
* @type { string }
|
|
2324
|
+
* @memberof HolderInputMessage
|
|
2325
|
+
*/
|
|
2326
|
+
type: string;
|
|
2327
|
+
/**
|
|
2328
|
+
* @description Raw input data to write to PTY
|
|
2329
|
+
* @type { string }
|
|
2330
|
+
* @memberof HolderInputMessage
|
|
2331
|
+
*/
|
|
2332
|
+
data: string;
|
|
2333
|
+
};
|
|
2334
|
+
|
|
2335
|
+
export function decodeHolderInputMessage(rawInput: unknown): HolderInputMessage | null {
|
|
2472
2336
|
if (isJSON(rawInput)) {
|
|
2473
|
-
const decodedType = decodeString(rawInput
|
|
2474
|
-
const
|
|
2337
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2338
|
+
const decodedData = decodeString(rawInput['data']);
|
|
2475
2339
|
|
|
2476
|
-
if (
|
|
2477
|
-
decodedType === null ||
|
|
2478
|
-
decodedText === null
|
|
2479
|
-
) {
|
|
2340
|
+
if (decodedType === null || decodedData === null) {
|
|
2480
2341
|
return null;
|
|
2481
2342
|
}
|
|
2482
2343
|
|
|
2483
2344
|
return {
|
|
2484
|
-
|
|
2485
|
-
|
|
2345
|
+
type: decodedType,
|
|
2346
|
+
data: decodedData,
|
|
2486
2347
|
};
|
|
2487
2348
|
}
|
|
2488
2349
|
return null;
|
|
2489
2350
|
}
|
|
2490
2351
|
|
|
2352
|
+
/**
|
|
2353
|
+
* @type { HolderResizeMessage }
|
|
2354
|
+
* @description Resize the PTY dimensions
|
|
2355
|
+
*/
|
|
2356
|
+
export type HolderResizeMessage = {
|
|
2357
|
+
/**
|
|
2358
|
+
* @type { string }
|
|
2359
|
+
* @memberof HolderResizeMessage
|
|
2360
|
+
*/
|
|
2361
|
+
type: string;
|
|
2362
|
+
/**
|
|
2363
|
+
* @description New width in columns
|
|
2364
|
+
* @type { number }
|
|
2365
|
+
* @memberof HolderResizeMessage
|
|
2366
|
+
*/
|
|
2367
|
+
cols: number;
|
|
2368
|
+
/**
|
|
2369
|
+
* @description New height in rows
|
|
2370
|
+
* @type { number }
|
|
2371
|
+
* @memberof HolderResizeMessage
|
|
2372
|
+
*/
|
|
2373
|
+
rows: number;
|
|
2374
|
+
};
|
|
2491
2375
|
|
|
2492
|
-
|
|
2493
|
-
export function decodeWsSessionOutput6(rawInput: unknown): null | WsSessionOutput6 {
|
|
2376
|
+
export function decodeHolderResizeMessage(rawInput: unknown): HolderResizeMessage | null {
|
|
2494
2377
|
if (isJSON(rawInput)) {
|
|
2495
|
-
const decodedType = decodeString(rawInput
|
|
2378
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2379
|
+
const decodedCols = decodeNumber(rawInput['cols']);
|
|
2380
|
+
const decodedRows = decodeNumber(rawInput['rows']);
|
|
2496
2381
|
|
|
2497
|
-
if (
|
|
2498
|
-
decodedType === null
|
|
2499
|
-
) {
|
|
2382
|
+
if (decodedType === null || decodedCols === null || decodedRows === null) {
|
|
2500
2383
|
return null;
|
|
2501
2384
|
}
|
|
2502
2385
|
|
|
2503
2386
|
return {
|
|
2504
|
-
type: decodedType
|
|
2387
|
+
type: decodedType,
|
|
2388
|
+
cols: decodedCols,
|
|
2389
|
+
rows: decodedRows,
|
|
2505
2390
|
};
|
|
2506
2391
|
}
|
|
2507
2392
|
return null;
|
|
2508
2393
|
}
|
|
2509
2394
|
|
|
2510
|
-
|
|
2395
|
+
/**
|
|
2396
|
+
* @type { HolderKillMessage }
|
|
2397
|
+
* @description Send a signal to the PTY process
|
|
2398
|
+
*/
|
|
2399
|
+
export type HolderKillMessage = {
|
|
2400
|
+
/**
|
|
2401
|
+
* @type { string }
|
|
2402
|
+
* @memberof HolderKillMessage
|
|
2403
|
+
*/
|
|
2404
|
+
type: string;
|
|
2405
|
+
/**
|
|
2406
|
+
* @description Signal name to send (default SIGTERM)
|
|
2407
|
+
* @type { string }
|
|
2408
|
+
* @memberof HolderKillMessage
|
|
2409
|
+
*/
|
|
2410
|
+
signal: string | null;
|
|
2411
|
+
};
|
|
2412
|
+
|
|
2413
|
+
export function decodeHolderKillMessage(rawInput: unknown): HolderKillMessage | null {
|
|
2511
2414
|
if (isJSON(rawInput)) {
|
|
2512
|
-
const
|
|
2415
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2416
|
+
const decodedSignal = decodeString(rawInput['signal']);
|
|
2513
2417
|
|
|
2514
|
-
if (
|
|
2515
|
-
decodedConnectedClients === null
|
|
2516
|
-
) {
|
|
2418
|
+
if (decodedType === null) {
|
|
2517
2419
|
return null;
|
|
2518
2420
|
}
|
|
2519
2421
|
|
|
2520
2422
|
return {
|
|
2521
|
-
|
|
2423
|
+
type: decodedType,
|
|
2424
|
+
signal: decodedSignal,
|
|
2522
2425
|
};
|
|
2523
2426
|
}
|
|
2524
2427
|
return null;
|
|
2525
2428
|
}
|
|
2526
2429
|
|
|
2430
|
+
export type HolderServerMessage =
|
|
2431
|
+
| CHolderServerMessageHolderInputMessage
|
|
2432
|
+
| CHolderServerMessageHolderResizeMessage
|
|
2433
|
+
| CHolderServerMessageHolderKillMessage;
|
|
2527
2434
|
|
|
2435
|
+
export function decodeHolderServerMessage(rawInput: unknown): HolderServerMessage | null {
|
|
2436
|
+
const result: HolderServerMessage | null =
|
|
2437
|
+
decodeCHolderServerMessageHolderInputMessage(rawInput) ??
|
|
2438
|
+
decodeCHolderServerMessageHolderResizeMessage(rawInput) ??
|
|
2439
|
+
decodeCHolderServerMessageHolderKillMessage(rawInput);
|
|
2528
2440
|
|
|
2529
|
-
export function decodeWsTerminalMessage(rawInput: unknown): null | WsTerminalMessage {
|
|
2530
|
-
const result: null | WsTerminalMessage =
|
|
2531
|
-
decodeCWsTerminalMessage1(rawInput)
|
|
2532
|
-
??
|
|
2533
|
-
decodeCWsTerminalMessage2(rawInput)
|
|
2534
|
-
??
|
|
2535
|
-
decodeCWsTerminalMessage3(rawInput)
|
|
2536
|
-
|
|
2537
|
-
;
|
|
2538
2441
|
return result;
|
|
2539
2442
|
}
|
|
2540
2443
|
|
|
2541
|
-
export
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2444
|
+
export class CHolderServerMessageHolderInputMessage {
|
|
2445
|
+
data: HolderInputMessage;
|
|
2446
|
+
constructor(data: HolderInputMessage) {
|
|
2447
|
+
this.data = data;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2545
2450
|
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2451
|
+
export function decodeCHolderServerMessageHolderInputMessage(
|
|
2452
|
+
rawInput: unknown
|
|
2453
|
+
): CHolderServerMessageHolderInputMessage | null {
|
|
2454
|
+
const result = decodeHolderInputMessage(rawInput);
|
|
2455
|
+
if (result === null) {
|
|
2456
|
+
return null;
|
|
2457
|
+
}
|
|
2458
|
+
return new CHolderServerMessageHolderInputMessage(result);
|
|
2459
|
+
}
|
|
2552
2460
|
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2461
|
+
export class CHolderServerMessageHolderResizeMessage {
|
|
2462
|
+
data: HolderResizeMessage;
|
|
2463
|
+
constructor(data: HolderResizeMessage) {
|
|
2464
|
+
this.data = data;
|
|
2557
2465
|
}
|
|
2558
|
-
return null;
|
|
2559
2466
|
}
|
|
2560
2467
|
|
|
2468
|
+
export function decodeCHolderServerMessageHolderResizeMessage(
|
|
2469
|
+
rawInput: unknown
|
|
2470
|
+
): CHolderServerMessageHolderResizeMessage | null {
|
|
2471
|
+
const result = decodeHolderResizeMessage(rawInput);
|
|
2472
|
+
if (result === null) {
|
|
2473
|
+
return null;
|
|
2474
|
+
}
|
|
2475
|
+
return new CHolderServerMessageHolderResizeMessage(result);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
export class CHolderServerMessageHolderKillMessage {
|
|
2479
|
+
data: HolderKillMessage;
|
|
2480
|
+
constructor(data: HolderKillMessage) {
|
|
2481
|
+
this.data = data;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
export function decodeCHolderServerMessageHolderKillMessage(
|
|
2486
|
+
rawInput: unknown
|
|
2487
|
+
): CHolderServerMessageHolderKillMessage | null {
|
|
2488
|
+
const result = decodeHolderKillMessage(rawInput);
|
|
2489
|
+
if (result === null) {
|
|
2490
|
+
return null;
|
|
2491
|
+
}
|
|
2492
|
+
return new CHolderServerMessageHolderKillMessage(result);
|
|
2493
|
+
}
|
|
2561
2494
|
|
|
2495
|
+
/**
|
|
2496
|
+
* @type { HolderInfoMessage }
|
|
2497
|
+
* @description Current holder state sent on connection
|
|
2498
|
+
*/
|
|
2499
|
+
export type HolderInfoMessage = {
|
|
2500
|
+
/**
|
|
2501
|
+
* @type { string }
|
|
2502
|
+
* @memberof HolderInfoMessage
|
|
2503
|
+
*/
|
|
2504
|
+
type: string;
|
|
2505
|
+
/**
|
|
2506
|
+
* @description PTY child process ID
|
|
2507
|
+
* @type { number }
|
|
2508
|
+
* @memberof HolderInfoMessage
|
|
2509
|
+
*/
|
|
2510
|
+
pid: number;
|
|
2511
|
+
/**
|
|
2512
|
+
* @description Whether the PTY process has exited
|
|
2513
|
+
* @type { boolean }
|
|
2514
|
+
* @memberof HolderInfoMessage
|
|
2515
|
+
*/
|
|
2516
|
+
exited: boolean;
|
|
2517
|
+
/**
|
|
2518
|
+
* @description Exit code if process has exited
|
|
2519
|
+
* @type { number }
|
|
2520
|
+
* @memberof HolderInfoMessage
|
|
2521
|
+
*/
|
|
2522
|
+
exitCode: number | null;
|
|
2523
|
+
};
|
|
2562
2524
|
|
|
2563
|
-
export function
|
|
2525
|
+
export function decodeHolderInfoMessage(rawInput: unknown): HolderInfoMessage | null {
|
|
2564
2526
|
if (isJSON(rawInput)) {
|
|
2565
|
-
const decodedType = decodeString(rawInput
|
|
2566
|
-
const
|
|
2567
|
-
const
|
|
2527
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2528
|
+
const decodedPid = decodeNumber(rawInput['pid']);
|
|
2529
|
+
const decodedExited = decodeBoolean(rawInput['exited']);
|
|
2530
|
+
const decodedExitCode = decodeNumber(rawInput['exitCode']);
|
|
2568
2531
|
|
|
2569
|
-
if (
|
|
2570
|
-
decodedType === null ||
|
|
2571
|
-
decodedCols === null ||
|
|
2572
|
-
decodedRows === null
|
|
2573
|
-
) {
|
|
2532
|
+
if (decodedType === null || decodedPid === null || decodedExited === null) {
|
|
2574
2533
|
return null;
|
|
2575
2534
|
}
|
|
2576
2535
|
|
|
2577
2536
|
return {
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2537
|
+
type: decodedType,
|
|
2538
|
+
pid: decodedPid,
|
|
2539
|
+
exited: decodedExited,
|
|
2540
|
+
exitCode: decodedExitCode,
|
|
2581
2541
|
};
|
|
2582
2542
|
}
|
|
2583
2543
|
return null;
|
|
2584
2544
|
}
|
|
2585
2545
|
|
|
2586
|
-
|
|
2546
|
+
/**
|
|
2547
|
+
* @type { HolderScrollbackMessage }
|
|
2548
|
+
* @description Full scrollback replay sent on connection
|
|
2549
|
+
*/
|
|
2550
|
+
export type HolderScrollbackMessage = {
|
|
2551
|
+
/**
|
|
2552
|
+
* @type { string }
|
|
2553
|
+
* @memberof HolderScrollbackMessage
|
|
2554
|
+
*/
|
|
2555
|
+
type: string;
|
|
2556
|
+
/**
|
|
2557
|
+
* @description Full scrollback buffer content
|
|
2558
|
+
* @type { string }
|
|
2559
|
+
* @memberof HolderScrollbackMessage
|
|
2560
|
+
*/
|
|
2561
|
+
data: string;
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2564
|
+
export function decodeHolderScrollbackMessage(rawInput: unknown): HolderScrollbackMessage | null {
|
|
2587
2565
|
if (isJSON(rawInput)) {
|
|
2588
|
-
const decodedType = decodeString(rawInput
|
|
2589
|
-
const
|
|
2566
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2567
|
+
const decodedData = decodeString(rawInput['data']);
|
|
2590
2568
|
|
|
2591
|
-
if (
|
|
2592
|
-
decodedType === null ||
|
|
2593
|
-
decodedSignal === null
|
|
2594
|
-
) {
|
|
2569
|
+
if (decodedType === null || decodedData === null) {
|
|
2595
2570
|
return null;
|
|
2596
2571
|
}
|
|
2597
2572
|
|
|
2598
2573
|
return {
|
|
2599
|
-
|
|
2600
|
-
|
|
2574
|
+
type: decodedType,
|
|
2575
|
+
data: decodedData,
|
|
2601
2576
|
};
|
|
2602
2577
|
}
|
|
2603
2578
|
return null;
|
|
2604
2579
|
}
|
|
2605
2580
|
|
|
2581
|
+
/**
|
|
2582
|
+
* @type { HolderOutputMessage }
|
|
2583
|
+
* @description PTY output chunk during normal operation
|
|
2584
|
+
*/
|
|
2585
|
+
export type HolderOutputMessage = {
|
|
2586
|
+
/**
|
|
2587
|
+
* @type { string }
|
|
2588
|
+
* @memberof HolderOutputMessage
|
|
2589
|
+
*/
|
|
2590
|
+
type: string;
|
|
2591
|
+
/**
|
|
2592
|
+
* @description Raw PTY output data
|
|
2593
|
+
* @type { string }
|
|
2594
|
+
* @memberof HolderOutputMessage
|
|
2595
|
+
*/
|
|
2596
|
+
data: string;
|
|
2597
|
+
};
|
|
2606
2598
|
|
|
2607
|
-
|
|
2608
|
-
export function decodeWsTerminalOutput(rawInput: unknown): null | WsTerminalOutput {
|
|
2609
|
-
const result: null | WsTerminalOutput =
|
|
2610
|
-
decodeCWsTerminalOutput1(rawInput)
|
|
2611
|
-
??
|
|
2612
|
-
decodeCWsTerminalOutput2(rawInput)
|
|
2613
|
-
??
|
|
2614
|
-
decodeCWsTerminalOutput3(rawInput)
|
|
2615
|
-
??
|
|
2616
|
-
decodeCWsTerminalOutput4(rawInput)
|
|
2617
|
-
|
|
2618
|
-
;
|
|
2619
|
-
return result;
|
|
2620
|
-
}
|
|
2621
|
-
|
|
2622
|
-
export function decodeWsTerminalOutput1(rawInput: unknown): null | WsTerminalOutput1 {
|
|
2599
|
+
export function decodeHolderOutputMessage(rawInput: unknown): HolderOutputMessage | null {
|
|
2623
2600
|
if (isJSON(rawInput)) {
|
|
2624
|
-
const decodedType = decodeString(rawInput
|
|
2625
|
-
const decodedData = decodeString(rawInput
|
|
2601
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2602
|
+
const decodedData = decodeString(rawInput['data']);
|
|
2626
2603
|
|
|
2627
|
-
if (
|
|
2628
|
-
decodedType === null ||
|
|
2629
|
-
decodedData === null
|
|
2630
|
-
) {
|
|
2604
|
+
if (decodedType === null || decodedData === null) {
|
|
2631
2605
|
return null;
|
|
2632
2606
|
}
|
|
2633
2607
|
|
|
2634
2608
|
return {
|
|
2609
|
+
type: decodedType,
|
|
2635
2610
|
data: decodedData,
|
|
2636
|
-
type: decodedType
|
|
2637
2611
|
};
|
|
2638
2612
|
}
|
|
2639
2613
|
return null;
|
|
2640
2614
|
}
|
|
2641
2615
|
|
|
2616
|
+
/**
|
|
2617
|
+
* @type { HolderExitMessage }
|
|
2618
|
+
* @description PTY process has exited
|
|
2619
|
+
*/
|
|
2620
|
+
export type HolderExitMessage = {
|
|
2621
|
+
/**
|
|
2622
|
+
* @type { string }
|
|
2623
|
+
* @memberof HolderExitMessage
|
|
2624
|
+
*/
|
|
2625
|
+
type: string;
|
|
2626
|
+
/**
|
|
2627
|
+
* @description Process exit code
|
|
2628
|
+
* @type { number }
|
|
2629
|
+
* @memberof HolderExitMessage
|
|
2630
|
+
*/
|
|
2631
|
+
code: number;
|
|
2632
|
+
/**
|
|
2633
|
+
* @description Signal that caused exit
|
|
2634
|
+
* @type { string }
|
|
2635
|
+
* @memberof HolderExitMessage
|
|
2636
|
+
*/
|
|
2637
|
+
signal: string | null;
|
|
2638
|
+
};
|
|
2642
2639
|
|
|
2643
|
-
|
|
2644
|
-
export function decodeWsTerminalOutput2(rawInput: unknown): null | WsTerminalOutput2 {
|
|
2640
|
+
export function decodeHolderExitMessage(rawInput: unknown): HolderExitMessage | null {
|
|
2645
2641
|
if (isJSON(rawInput)) {
|
|
2646
|
-
const decodedType = decodeString(rawInput
|
|
2647
|
-
const decodedCode = decodeNumber(rawInput
|
|
2648
|
-
const decodedSignal = decodeString(rawInput
|
|
2642
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2643
|
+
const decodedCode = decodeNumber(rawInput['code']);
|
|
2644
|
+
const decodedSignal = decodeString(rawInput['signal']);
|
|
2649
2645
|
|
|
2650
|
-
if (
|
|
2651
|
-
decodedType === null ||
|
|
2652
|
-
decodedCode === null
|
|
2653
|
-
) {
|
|
2646
|
+
if (decodedType === null || decodedCode === null) {
|
|
2654
2647
|
return null;
|
|
2655
2648
|
}
|
|
2656
2649
|
|
|
2657
2650
|
return {
|
|
2651
|
+
type: decodedType,
|
|
2658
2652
|
code: decodedCode,
|
|
2659
2653
|
signal: decodedSignal,
|
|
2660
|
-
type: decodedType
|
|
2661
2654
|
};
|
|
2662
2655
|
}
|
|
2663
2656
|
return null;
|
|
2664
2657
|
}
|
|
2665
2658
|
|
|
2666
|
-
|
|
2659
|
+
/**
|
|
2660
|
+
* @type { HolderActivityMessage }
|
|
2661
|
+
* @description Terminal activity state change (active/idle)
|
|
2662
|
+
*/
|
|
2663
|
+
export type HolderActivityMessage = {
|
|
2664
|
+
/**
|
|
2665
|
+
* @type { string }
|
|
2666
|
+
* @memberof HolderActivityMessage
|
|
2667
|
+
*/
|
|
2668
|
+
type: string;
|
|
2669
|
+
/**
|
|
2670
|
+
* @description Whether the terminal is currently producing output
|
|
2671
|
+
* @type { boolean }
|
|
2672
|
+
* @memberof HolderActivityMessage
|
|
2673
|
+
*/
|
|
2674
|
+
active: boolean;
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
export function decodeHolderActivityMessage(rawInput: unknown): HolderActivityMessage | null {
|
|
2667
2678
|
if (isJSON(rawInput)) {
|
|
2668
|
-
const decodedType = decodeString(rawInput
|
|
2669
|
-
const
|
|
2670
|
-
const decodedChunk = decodeNumber(rawInput.chunk);
|
|
2671
|
-
const decodedTotal = decodeNumber(rawInput.total);
|
|
2679
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2680
|
+
const decodedActive = decodeBoolean(rawInput['active']);
|
|
2672
2681
|
|
|
2673
|
-
if (
|
|
2674
|
-
decodedType === null ||
|
|
2675
|
-
decodedData === null ||
|
|
2676
|
-
decodedChunk === null ||
|
|
2677
|
-
decodedTotal === null
|
|
2678
|
-
) {
|
|
2682
|
+
if (decodedType === null || decodedActive === null) {
|
|
2679
2683
|
return null;
|
|
2680
2684
|
}
|
|
2681
2685
|
|
|
2682
2686
|
return {
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
total: decodedTotal,
|
|
2686
|
-
type: decodedType
|
|
2687
|
+
type: decodedType,
|
|
2688
|
+
active: decodedActive,
|
|
2687
2689
|
};
|
|
2688
2690
|
}
|
|
2689
2691
|
return null;
|
|
2690
2692
|
}
|
|
2691
2693
|
|
|
2694
|
+
/**
|
|
2695
|
+
* @type { HolderCwdMessage }
|
|
2696
|
+
* @description Current working directory change detected via OSC 7
|
|
2697
|
+
*/
|
|
2698
|
+
export type HolderCwdMessage = {
|
|
2699
|
+
/**
|
|
2700
|
+
* @type { string }
|
|
2701
|
+
* @memberof HolderCwdMessage
|
|
2702
|
+
*/
|
|
2703
|
+
type: string;
|
|
2704
|
+
/**
|
|
2705
|
+
* @description Absolute path of the new working directory
|
|
2706
|
+
* @type { string }
|
|
2707
|
+
* @memberof HolderCwdMessage
|
|
2708
|
+
*/
|
|
2709
|
+
path: string;
|
|
2710
|
+
};
|
|
2692
2711
|
|
|
2693
|
-
|
|
2694
|
-
export function decodeWsTerminalOutput4(rawInput: unknown): null | WsTerminalOutput4 {
|
|
2712
|
+
export function decodeHolderCwdMessage(rawInput: unknown): HolderCwdMessage | null {
|
|
2695
2713
|
if (isJSON(rawInput)) {
|
|
2696
|
-
const decodedType = decodeString(rawInput
|
|
2697
|
-
const
|
|
2714
|
+
const decodedType = decodeString(rawInput['type']);
|
|
2715
|
+
const decodedPath = decodeString(rawInput['path']);
|
|
2698
2716
|
|
|
2699
|
-
if (
|
|
2700
|
-
decodedType === null ||
|
|
2701
|
-
decodedMessage === null
|
|
2702
|
-
) {
|
|
2717
|
+
if (decodedType === null || decodedPath === null) {
|
|
2703
2718
|
return null;
|
|
2704
2719
|
}
|
|
2705
2720
|
|
|
2706
2721
|
return {
|
|
2707
|
-
|
|
2708
|
-
|
|
2722
|
+
type: decodedType,
|
|
2723
|
+
path: decodedPath,
|
|
2709
2724
|
};
|
|
2710
2725
|
}
|
|
2711
2726
|
return null;
|
|
2712
2727
|
}
|
|
2713
2728
|
|
|
2714
|
-
export
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2729
|
+
export type HolderClientMessage =
|
|
2730
|
+
| CHolderClientMessageHolderInfoMessage
|
|
2731
|
+
| CHolderClientMessageHolderScrollbackMessage
|
|
2732
|
+
| CHolderClientMessageHolderOutputMessage
|
|
2733
|
+
| CHolderClientMessageHolderExitMessage
|
|
2734
|
+
| CHolderClientMessageHolderActivityMessage
|
|
2735
|
+
| CHolderClientMessageHolderCwdMessage;
|
|
2718
2736
|
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
)
|
|
2723
|
-
|
|
2724
|
-
|
|
2737
|
+
export function decodeHolderClientMessage(rawInput: unknown): HolderClientMessage | null {
|
|
2738
|
+
const result: HolderClientMessage | null =
|
|
2739
|
+
decodeCHolderClientMessageHolderInfoMessage(rawInput) ??
|
|
2740
|
+
decodeCHolderClientMessageHolderScrollbackMessage(rawInput) ??
|
|
2741
|
+
decodeCHolderClientMessageHolderOutputMessage(rawInput) ??
|
|
2742
|
+
decodeCHolderClientMessageHolderExitMessage(rawInput) ??
|
|
2743
|
+
decodeCHolderClientMessageHolderActivityMessage(rawInput) ??
|
|
2744
|
+
decodeCHolderClientMessageHolderCwdMessage(rawInput);
|
|
2725
2745
|
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2746
|
+
return result;
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
export class CHolderClientMessageHolderInfoMessage {
|
|
2750
|
+
data: HolderInfoMessage;
|
|
2751
|
+
constructor(data: HolderInfoMessage) {
|
|
2752
|
+
this.data = data;
|
|
2730
2753
|
}
|
|
2731
|
-
return null;
|
|
2732
2754
|
}
|
|
2733
2755
|
|
|
2756
|
+
export function decodeCHolderClientMessageHolderInfoMessage(
|
|
2757
|
+
rawInput: unknown
|
|
2758
|
+
): CHolderClientMessageHolderInfoMessage | null {
|
|
2759
|
+
const result = decodeHolderInfoMessage(rawInput);
|
|
2760
|
+
if (result === null) {
|
|
2761
|
+
return null;
|
|
2762
|
+
}
|
|
2763
|
+
return new CHolderClientMessageHolderInfoMessage(result);
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
export class CHolderClientMessageHolderScrollbackMessage {
|
|
2767
|
+
data: HolderScrollbackMessage;
|
|
2768
|
+
constructor(data: HolderScrollbackMessage) {
|
|
2769
|
+
this.data = data;
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
export function decodeCHolderClientMessageHolderScrollbackMessage(
|
|
2774
|
+
rawInput: unknown
|
|
2775
|
+
): CHolderClientMessageHolderScrollbackMessage | null {
|
|
2776
|
+
const result = decodeHolderScrollbackMessage(rawInput);
|
|
2777
|
+
if (result === null) {
|
|
2778
|
+
return null;
|
|
2779
|
+
}
|
|
2780
|
+
return new CHolderClientMessageHolderScrollbackMessage(result);
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
export class CHolderClientMessageHolderOutputMessage {
|
|
2784
|
+
data: HolderOutputMessage;
|
|
2785
|
+
constructor(data: HolderOutputMessage) {
|
|
2786
|
+
this.data = data;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
export function decodeCHolderClientMessageHolderOutputMessage(
|
|
2791
|
+
rawInput: unknown
|
|
2792
|
+
): CHolderClientMessageHolderOutputMessage | null {
|
|
2793
|
+
const result = decodeHolderOutputMessage(rawInput);
|
|
2794
|
+
if (result === null) {
|
|
2795
|
+
return null;
|
|
2796
|
+
}
|
|
2797
|
+
return new CHolderClientMessageHolderOutputMessage(result);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
export class CHolderClientMessageHolderExitMessage {
|
|
2801
|
+
data: HolderExitMessage;
|
|
2802
|
+
constructor(data: HolderExitMessage) {
|
|
2803
|
+
this.data = data;
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
export function decodeCHolderClientMessageHolderExitMessage(
|
|
2808
|
+
rawInput: unknown
|
|
2809
|
+
): CHolderClientMessageHolderExitMessage | null {
|
|
2810
|
+
const result = decodeHolderExitMessage(rawInput);
|
|
2811
|
+
if (result === null) {
|
|
2812
|
+
return null;
|
|
2813
|
+
}
|
|
2814
|
+
return new CHolderClientMessageHolderExitMessage(result);
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
export class CHolderClientMessageHolderActivityMessage {
|
|
2818
|
+
data: HolderActivityMessage;
|
|
2819
|
+
constructor(data: HolderActivityMessage) {
|
|
2820
|
+
this.data = data;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2734
2823
|
|
|
2824
|
+
export function decodeCHolderClientMessageHolderActivityMessage(
|
|
2825
|
+
rawInput: unknown
|
|
2826
|
+
): CHolderClientMessageHolderActivityMessage | null {
|
|
2827
|
+
const result = decodeHolderActivityMessage(rawInput);
|
|
2828
|
+
if (result === null) {
|
|
2829
|
+
return null;
|
|
2830
|
+
}
|
|
2831
|
+
return new CHolderClientMessageHolderActivityMessage(result);
|
|
2832
|
+
}
|
|
2735
2833
|
|
|
2834
|
+
export class CHolderClientMessageHolderCwdMessage {
|
|
2835
|
+
data: HolderCwdMessage;
|
|
2836
|
+
constructor(data: HolderCwdMessage) {
|
|
2837
|
+
this.data = data;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2736
2840
|
|
|
2841
|
+
export function decodeCHolderClientMessageHolderCwdMessage(
|
|
2842
|
+
rawInput: unknown
|
|
2843
|
+
): CHolderClientMessageHolderCwdMessage | null {
|
|
2844
|
+
const result = decodeHolderCwdMessage(rawInput);
|
|
2845
|
+
if (result === null) {
|
|
2846
|
+
return null;
|
|
2847
|
+
}
|
|
2848
|
+
return new CHolderClientMessageHolderCwdMessage(result);
|
|
2849
|
+
}
|