offsite 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/apps/server/dist/args.js +11 -0
- package/apps/server/dist/claude.js +207 -0
- package/apps/server/dist/config.js +185 -0
- package/apps/server/dist/content.js +172 -0
- package/apps/server/dist/db.js +13 -0
- package/apps/server/dist/files.js +50 -0
- package/apps/server/dist/git.js +133 -0
- package/apps/server/dist/history.js +137 -0
- package/apps/server/dist/hub.js +10 -0
- package/apps/server/dist/main.js +64 -0
- package/apps/server/dist/projects.js +92 -0
- package/apps/server/dist/protocol.js +20 -0
- package/apps/server/dist/push.js +152 -0
- package/apps/server/dist/run.js +375 -0
- package/apps/server/dist/runs.js +102 -0
- package/apps/server/dist/schemes.js +262 -0
- package/apps/server/dist/sessions.js +65 -0
- package/apps/server/dist/socket.js +149 -0
- package/apps/server/dist/storage.js +22 -0
- package/apps/server/dist/terminal/alerts.js +145 -0
- package/apps/server/dist/terminal/process.js +207 -0
- package/apps/server/dist/terminal/shell-check.js +91 -0
- package/apps/server/dist/terminal/shell-integration.js +112 -0
- package/apps/server/dist/terminal/terminal.js +402 -0
- package/apps/server/src/terminal/shell-integration/bash/offsite.bash +112 -0
- package/apps/server/src/terminal/shell-integration/fish/offsite.fish +22 -0
- package/apps/server/src/terminal/shell-integration/zsh/.zshenv +100 -0
- package/apps/web/dist/assets/CaskaydiaCove-Bold-EtG3C8NJ.woff2 +0 -0
- package/apps/web/dist/assets/CaskaydiaCove-Regular-C8p8BuDw.woff2 +0 -0
- package/apps/web/dist/assets/FiraCode-Bold-CWkMdXEH.woff2 +0 -0
- package/apps/web/dist/assets/FiraCode-Regular-DlIV_a-6.woff2 +0 -0
- package/apps/web/dist/assets/Hack-Bold-CJ2nw9Fn.woff2 +0 -0
- package/apps/web/dist/assets/Hack-Regular-DQT7wDXD.woff2 +0 -0
- package/apps/web/dist/assets/JetBrainsMono-Bold-C3RVijod.woff2 +0 -0
- package/apps/web/dist/assets/JetBrainsMono-Regular-BhNseNRl.woff2 +0 -0
- package/apps/web/dist/assets/abap-CLvhMVsD.js +1 -0
- package/apps/web/dist/assets/actionscript-3-Cs6JJXT5.js +1 -0
- package/apps/web/dist/assets/ada-X3Y2mlq2.js +1 -0
- package/apps/web/dist/assets/ahk-DwADkxyd.js +1 -0
- package/apps/web/dist/assets/ahk2-_6rzW9BS.js +1 -0
- package/apps/web/dist/assets/andromeeda-vGVdxbeo.js +1 -0
- package/apps/web/dist/assets/angular-html-Oa9dnZbT.js +1 -0
- package/apps/web/dist/assets/angular-ts-F_BIbY2H.js +1 -0
- package/apps/web/dist/assets/apache-U0d_L8uA.js +1 -0
- package/apps/web/dist/assets/apex-KFGFyKwG.js +1 -0
- package/apps/web/dist/assets/apl-D7AuiKiV.js +1 -0
- package/apps/web/dist/assets/applescript-CCn79oCD.js +1 -0
- package/apps/web/dist/assets/ara-4CJ0cIlV.js +1 -0
- package/apps/web/dist/assets/asciidoc-SCjQUq34.js +1 -0
- package/apps/web/dist/assets/asm-Cmm7eHzH.js +1 -0
- package/apps/web/dist/assets/astro-DnpymQyW.js +1 -0
- package/apps/web/dist/assets/aurora-x-CDeNXAV0.js +1 -0
- package/apps/web/dist/assets/awk-BWXHIvNe.js +1 -0
- package/apps/web/dist/assets/ayu-dark-DluEY0Gj.js +1 -0
- package/apps/web/dist/assets/ayu-light-C3h-C4tm.js +1 -0
- package/apps/web/dist/assets/ayu-mirage-Bqwy1Gya.js +1 -0
- package/apps/web/dist/assets/ballerina-B7ZEbQpA.js +1 -0
- package/apps/web/dist/assets/bat-qdxAdBWQ.js +1 -0
- package/apps/web/dist/assets/beancount-C2IN4Vk8.js +1 -0
- package/apps/web/dist/assets/berry-DKpUyyne.js +1 -0
- package/apps/web/dist/assets/bibtex-Ci_nEsc7.js +1 -0
- package/apps/web/dist/assets/bicep-CUHmPFLl.js +1 -0
- package/apps/web/dist/assets/bird2-CYIUgYqB.js +1 -0
- package/apps/web/dist/assets/blade-CZZrW0iI.js +1 -0
- package/apps/web/dist/assets/bsl-_VjlB9mv.js +1 -0
- package/apps/web/dist/assets/c-V_Rix0w2.js +1 -0
- package/apps/web/dist/assets/c3-D0apG41V.js +1 -0
- package/apps/web/dist/assets/cadence-CQ2zXKGN.js +1 -0
- package/apps/web/dist/assets/cairo-DLTphjLi.js +1 -0
- package/apps/web/dist/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
- package/apps/web/dist/assets/catppuccin-latte-CtsyrtPq.js +1 -0
- package/apps/web/dist/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
- package/apps/web/dist/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
- package/apps/web/dist/assets/chapel-fGtLLMYq.js +1 -0
- package/apps/web/dist/assets/clarity-CtfBBspg.js +1 -0
- package/apps/web/dist/assets/clojure-DqKBuwfJ.js +1 -0
- package/apps/web/dist/assets/cmake-Bj61d0ZC.js +1 -0
- package/apps/web/dist/assets/cobol-BFOTnbFa.js +1 -0
- package/apps/web/dist/assets/codeowners-C8r90Shi.js +1 -0
- package/apps/web/dist/assets/codeql-oeQT6MSM.js +1 -0
- package/apps/web/dist/assets/coffee-BdvfipEg.js +1 -0
- package/apps/web/dist/assets/common-lisp-Cv5bFMCO.js +1 -0
- package/apps/web/dist/assets/coq-CGaSfhwR.js +1 -0
- package/apps/web/dist/assets/cpp-D_NFR3H2.js +1 -0
- package/apps/web/dist/assets/crystal-BM2vkBPa.js +1 -0
- package/apps/web/dist/assets/csharp-dmMxLVLW.js +1 -0
- package/apps/web/dist/assets/css-Byur6C5q.js +1 -0
- package/apps/web/dist/assets/csv-Dx-8-gkx.js +1 -0
- package/apps/web/dist/assets/cue-CE9AQfxI.js +1 -0
- package/apps/web/dist/assets/cypher-ClKdZ_lG.js +1 -0
- package/apps/web/dist/assets/d-qD-0Kul2.js +1 -0
- package/apps/web/dist/assets/dark-plus-Cs2F2srj.js +1 -0
- package/apps/web/dist/assets/dart-CHZY9Xhz.js +1 -0
- package/apps/web/dist/assets/dax-BkyTk9wS.js +1 -0
- package/apps/web/dist/assets/desktop-Dlh5hvp9.js +1 -0
- package/apps/web/dist/assets/diff-woXpYk--.js +1 -0
- package/apps/web/dist/assets/docker-IyjqRm3v.js +1 -0
- package/apps/web/dist/assets/dotenv-CuH5my32.js +1 -0
- package/apps/web/dist/assets/dracula-BHWKrbxM.js +1 -0
- package/apps/web/dist/assets/dracula-soft-5eyTD99u.js +1 -0
- package/apps/web/dist/assets/dream-maker-DW3nJb8Q.js +1 -0
- package/apps/web/dist/assets/edge-CP-KL2DQ.js +1 -0
- package/apps/web/dist/assets/elixir-CiO075Fh.js +1 -0
- package/apps/web/dist/assets/elm-DIyG-d95.js +1 -0
- package/apps/web/dist/assets/emacs-lisp-DR2vtWaj.js +1 -0
- package/apps/web/dist/assets/erb-DHZK6WKc.js +1 -0
- package/apps/web/dist/assets/erlang-Cphh6RMH.js +1 -0
- package/apps/web/dist/assets/everforest-dark-sB-x3p7T.js +1 -0
- package/apps/web/dist/assets/everforest-light-Df2xbC6M.js +1 -0
- package/apps/web/dist/assets/fennel-DQxkIbk2.js +1 -0
- package/apps/web/dist/assets/fish-BJitypiv.js +1 -0
- package/apps/web/dist/assets/fluent-C03EYrpw.js +1 -0
- package/apps/web/dist/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
- package/apps/web/dist/assets/fortran-free-form-CYNrtFtB.js +1 -0
- package/apps/web/dist/assets/fsharp-D13ZGOAj.js +1 -0
- package/apps/web/dist/assets/gdresource-xMC7jr7x.js +1 -0
- package/apps/web/dist/assets/gdscript-DYvRD3hg.js +1 -0
- package/apps/web/dist/assets/gdshader-CBce3t8t.js +1 -0
- package/apps/web/dist/assets/genie-CV2tkWYe.js +1 -0
- package/apps/web/dist/assets/gherkin-DExj1W_8.js +1 -0
- package/apps/web/dist/assets/ghostty-vt-CQAu1Gs5.wasm +0 -0
- package/apps/web/dist/assets/git-commit-BSykSTBG.js +1 -0
- package/apps/web/dist/assets/git-rebase-CxXKbwiy.js +1 -0
- package/apps/web/dist/assets/github-dark-C-LZuMrd.js +1 -0
- package/apps/web/dist/assets/github-dark-default-DXG-b-1a.js +1 -0
- package/apps/web/dist/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
- package/apps/web/dist/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
- package/apps/web/dist/assets/github-light-EUqPIrTm.js +1 -0
- package/apps/web/dist/assets/github-light-default-BXViO-2h.js +1 -0
- package/apps/web/dist/assets/github-light-high-contrast-B68TUdTA.js +1 -0
- package/apps/web/dist/assets/gleam-CSRkHgEL.js +1 -0
- package/apps/web/dist/assets/glimmer-js-BUhQC_gD.js +1 -0
- package/apps/web/dist/assets/glimmer-ts-D2lLByyw.js +1 -0
- package/apps/web/dist/assets/glsl-BMvlWqE_.js +1 -0
- package/apps/web/dist/assets/gn-CAXYAgV-.js +1 -0
- package/apps/web/dist/assets/gnuplot-7GGW24-e.js +1 -0
- package/apps/web/dist/assets/go-rLFTqkRN.js +1 -0
- package/apps/web/dist/assets/graphql-D9UFk_fJ.js +1 -0
- package/apps/web/dist/assets/groovy-CacY0gHj.js +1 -0
- package/apps/web/dist/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
- package/apps/web/dist/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
- package/apps/web/dist/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
- package/apps/web/dist/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
- package/apps/web/dist/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
- package/apps/web/dist/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
- package/apps/web/dist/assets/hack-BZAO0Jc2.js +1 -0
- package/apps/web/dist/assets/haml-Dm5wroII.js +1 -0
- package/apps/web/dist/assets/handlebars-C9L1Bn7f.js +1 -0
- package/apps/web/dist/assets/haskell-D8IpX4py.js +1 -0
- package/apps/web/dist/assets/haxe-C8oCnwJJ.js +1 -0
- package/apps/web/dist/assets/hcl-Dh228itO.js +1 -0
- package/apps/web/dist/assets/hjson-CxZEssPk.js +1 -0
- package/apps/web/dist/assets/hlsl-Cvrh5tZx.js +1 -0
- package/apps/web/dist/assets/horizon-CE9ld1lL.js +1 -0
- package/apps/web/dist/assets/horizon-bright-DSNQnXHK.js +1 -0
- package/apps/web/dist/assets/houston-CsvMBhTu.js +1 -0
- package/apps/web/dist/assets/html-Bz91Luf0.js +1 -0
- package/apps/web/dist/assets/html-derivative-hIdjVrpA.js +1 -0
- package/apps/web/dist/assets/http-AWG6aeFM.js +1 -0
- package/apps/web/dist/assets/hurl-pSGcpqgh.js +1 -0
- package/apps/web/dist/assets/hxml-Dcm88srW.js +1 -0
- package/apps/web/dist/assets/hy-CZbG8q4J.js +1 -0
- package/apps/web/dist/assets/imba-DsUTQ-LC.js +1 -0
- package/apps/web/dist/assets/index-BiLbXfDN.js +899 -0
- package/apps/web/dist/assets/index-DQIK-TpZ.css +2 -0
- package/apps/web/dist/assets/ini-B5eOa1yu.js +1 -0
- package/apps/web/dist/assets/java-D_CyC-X4.js +1 -0
- package/apps/web/dist/assets/javascript-PK4jkG9t.js +1 -0
- package/apps/web/dist/assets/jinja-Cu3wzgkz.js +1 -0
- package/apps/web/dist/assets/jison-CHevE1W8.js +1 -0
- package/apps/web/dist/assets/json-DPTkd0bP.js +1 -0
- package/apps/web/dist/assets/json5-BR5RXkoi.js +1 -0
- package/apps/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
- package/apps/web/dist/assets/jsonl-CmCQp5Yx.js +1 -0
- package/apps/web/dist/assets/jsonnet-CJTPZ8u_.js +1 -0
- package/apps/web/dist/assets/jssm-DXw9l8Rf.js +1 -0
- package/apps/web/dist/assets/jsx-DcsDzCOA.js +1 -0
- package/apps/web/dist/assets/julia-B9tMVOL0.js +1 -0
- package/apps/web/dist/assets/just-BHIhrE9N.js +1 -0
- package/apps/web/dist/assets/kanagawa-dragon-Bozd7klA.js +1 -0
- package/apps/web/dist/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
- package/apps/web/dist/assets/kanagawa-wave-BML5mF2J.js +1 -0
- package/apps/web/dist/assets/kdl-CsD5j6eV.js +1 -0
- package/apps/web/dist/assets/kotlin-DhhofPvG.js +1 -0
- package/apps/web/dist/assets/kusto-C7mF5XQf.js +1 -0
- package/apps/web/dist/assets/laserwave-C_8bwKvT.js +1 -0
- package/apps/web/dist/assets/latex-CY05HK-G.js +1 -0
- package/apps/web/dist/assets/lean-CewbzKMR.js +1 -0
- package/apps/web/dist/assets/less-DVTAwKKz.js +1 -0
- package/apps/web/dist/assets/light-plus-DVQuIRkW.js +1 -0
- package/apps/web/dist/assets/liquid-DJaL8XK2.js +1 -0
- package/apps/web/dist/assets/llvm-DqHOMS-s.js +1 -0
- package/apps/web/dist/assets/log-BNLmms1o.js +1 -0
- package/apps/web/dist/assets/logo-Cluzi2Zq.js +1 -0
- package/apps/web/dist/assets/lua-BfaWUinJ.js +1 -0
- package/apps/web/dist/assets/luau-VGWVLoqX.js +1 -0
- package/apps/web/dist/assets/make-Dixweg8N.js +1 -0
- package/apps/web/dist/assets/markdown-BYOwaDjH.js +1 -0
- package/apps/web/dist/assets/marko-0Lc0z7w6.js +1 -0
- package/apps/web/dist/assets/material-theme-Bm3Qr25_.js +1 -0
- package/apps/web/dist/assets/material-theme-darker-2IIEA8gg.js +1 -0
- package/apps/web/dist/assets/material-theme-lighter-uhdI0v04.js +1 -0
- package/apps/web/dist/assets/material-theme-ocean-CHQ94UKr.js +1 -0
- package/apps/web/dist/assets/material-theme-palenight-B5W6OYN7.js +1 -0
- package/apps/web/dist/assets/matlab-D7qyCx1q.js +1 -0
- package/apps/web/dist/assets/mdc-DEhXNYDZ.js +1 -0
- package/apps/web/dist/assets/mdx-DQZ5AkYe.js +1 -0
- package/apps/web/dist/assets/mermaid-BxpfTIzt.js +1 -0
- package/apps/web/dist/assets/min-dark-BSWPekZh.js +1 -0
- package/apps/web/dist/assets/min-light-DDpmG2fV.js +1 -0
- package/apps/web/dist/assets/mipsasm-BMqwQI7S.js +1 -0
- package/apps/web/dist/assets/mojo-fg40_ntQ.js +1 -0
- package/apps/web/dist/assets/monokai-BscAjiQZ.js +1 -0
- package/apps/web/dist/assets/moonbit-D9W784E_.js +1 -0
- package/apps/web/dist/assets/move-BYnGhZoM.js +1 -0
- package/apps/web/dist/assets/narrat-_X_XdTYD.js +1 -0
- package/apps/web/dist/assets/nextflow-CSgcYZcx.js +1 -0
- package/apps/web/dist/assets/nextflow-groovy-D7IRt6Pp.js +1 -0
- package/apps/web/dist/assets/nginx-DLuBebI5.js +1 -0
- package/apps/web/dist/assets/night-owl-DhmEMT88.js +1 -0
- package/apps/web/dist/assets/night-owl-light-eJ-hLW7d.js +1 -0
- package/apps/web/dist/assets/nim-BIJh7lZB.js +1 -0
- package/apps/web/dist/assets/nix-IvuFDN5E.js +1 -0
- package/apps/web/dist/assets/nord-Cb4Vim4T.js +1 -0
- package/apps/web/dist/assets/nsis-CjNLYCLg.js +1 -0
- package/apps/web/dist/assets/nushell--0fT3PI1.js +1 -0
- package/apps/web/dist/assets/objective-c-D1A_Heim.js +1 -0
- package/apps/web/dist/assets/objective-cpp-BsSzOQcm.js +1 -0
- package/apps/web/dist/assets/ocaml-O90oeIOV.js +1 -0
- package/apps/web/dist/assets/odin-B1RWQWA5.js +1 -0
- package/apps/web/dist/assets/one-dark-pro-C6YyR8OD.js +1 -0
- package/apps/web/dist/assets/one-light-D7Lr4KcI.js +1 -0
- package/apps/web/dist/assets/openscad-BUDT5pXO.js +1 -0
- package/apps/web/dist/assets/org-BFpxb2WJ.js +1 -0
- package/apps/web/dist/assets/pascal-4ZHwLPI5.js +1 -0
- package/apps/web/dist/assets/perl-DHbDMq2q.js +1 -0
- package/apps/web/dist/assets/php-BcVbiJpZ.js +1 -0
- package/apps/web/dist/assets/pierre-dark-CpLgRqie.js +1 -0
- package/apps/web/dist/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
- package/apps/web/dist/assets/pierre-dark-soft-kZQmAZld.js +1 -0
- package/apps/web/dist/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
- package/apps/web/dist/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
- package/apps/web/dist/assets/pierre-light-CoaEpmwp.js +1 -0
- package/apps/web/dist/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
- package/apps/web/dist/assets/pierre-light-soft-lWLdNTOI.js +1 -0
- package/apps/web/dist/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
- package/apps/web/dist/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
- package/apps/web/dist/assets/pkl-ot-7Btpt.js +1 -0
- package/apps/web/dist/assets/plastic-DQwYfKfQ.js +1 -0
- package/apps/web/dist/assets/plsql-DGHpHOYJ.js +1 -0
- package/apps/web/dist/assets/po-BiJDBrnU.js +1 -0
- package/apps/web/dist/assets/poimandres-DRFjx7u4.js +1 -0
- package/apps/web/dist/assets/polar-C7UOKdEL.js +1 -0
- package/apps/web/dist/assets/postcss-BXeXVLqQ.js +1 -0
- package/apps/web/dist/assets/powerquery-DNMTfnFr.js +1 -0
- package/apps/web/dist/assets/powershell-QtSnmXcu.js +1 -0
- package/apps/web/dist/assets/prisma-DMgNhnYS.js +1 -0
- package/apps/web/dist/assets/prolog-iXnhIJG7.js +1 -0
- package/apps/web/dist/assets/proto-DB4EqR-F.js +1 -0
- package/apps/web/dist/assets/pug-bdfyK-rS.js +1 -0
- package/apps/web/dist/assets/puppet-CDv2pdJW.js +1 -0
- package/apps/web/dist/assets/purescript-9MfHhQsQ.js +1 -0
- package/apps/web/dist/assets/python-gzcpVVnB.js +1 -0
- package/apps/web/dist/assets/qml-BC2D8eWk.js +1 -0
- package/apps/web/dist/assets/qmldir-DCQb3MpD.js +1 -0
- package/apps/web/dist/assets/qss-Fe1Jh2GI.js +1 -0
- package/apps/web/dist/assets/r-O3zbZ-YT.js +1 -0
- package/apps/web/dist/assets/racket-DcIDlBhZ.js +1 -0
- package/apps/web/dist/assets/raku-B3gFvitq.js +1 -0
- package/apps/web/dist/assets/razor-Ffnu5_vD.js +1 -0
- package/apps/web/dist/assets/rbs-C0MpOrj4.js +1 -0
- package/apps/web/dist/assets/red-CYlAq2b0.js +1 -0
- package/apps/web/dist/assets/reg-CRGYupPL.js +1 -0
- package/apps/web/dist/assets/regexp-dnbUAgjx.js +1 -0
- package/apps/web/dist/assets/rel-BtDbiS_P.js +1 -0
- package/apps/web/dist/assets/riscv-Ckw8ddFX.js +1 -0
- package/apps/web/dist/assets/ron-VUp2lXgN.js +1 -0
- package/apps/web/dist/assets/rose-pine-aMsaMD1D.js +1 -0
- package/apps/web/dist/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
- package/apps/web/dist/assets/rose-pine-moon-DO-qXg-I.js +1 -0
- package/apps/web/dist/assets/rosmsg-CAekHB0j.js +1 -0
- package/apps/web/dist/assets/rst-DJfy2dSm.js +1 -0
- package/apps/web/dist/assets/ruby-DGEpA0mD.js +1 -0
- package/apps/web/dist/assets/rust-DpiIf5JO.js +1 -0
- package/apps/web/dist/assets/sas-CZvL8X8k.js +1 -0
- package/apps/web/dist/assets/sass-DXrisJhu.js +1 -0
- package/apps/web/dist/assets/scala-BiFt_7mu.js +1 -0
- package/apps/web/dist/assets/scheme-DQCgrYNe.js +1 -0
- package/apps/web/dist/assets/scss-BtNSCzZB.js +1 -0
- package/apps/web/dist/assets/sdbl-bTVj8UrX.js +1 -0
- package/apps/web/dist/assets/shaderlab-TOUzSsQk.js +1 -0
- package/apps/web/dist/assets/shellscript-uR-sOZlr.js +1 -0
- package/apps/web/dist/assets/shellsession-BT-Jl4S5.js +1 -0
- package/apps/web/dist/assets/slack-dark-DnToyrRv.js +1 -0
- package/apps/web/dist/assets/slack-ochin-B2OO5cIa.js +1 -0
- package/apps/web/dist/assets/smalltalk-BHpQb5nM.js +1 -0
- package/apps/web/dist/assets/smithy-Dgaz7aur.js +1 -0
- package/apps/web/dist/assets/snazzy-light-4G7pJPwS.js +1 -0
- package/apps/web/dist/assets/solarized-dark-b97czJOk.js +1 -0
- package/apps/web/dist/assets/solarized-light-DFPxpIYQ.js +1 -0
- package/apps/web/dist/assets/solidity-Bj7E1mRn.js +1 -0
- package/apps/web/dist/assets/soy-BjfL_vrj.js +1 -0
- package/apps/web/dist/assets/sparql-D_iOobhT.js +1 -0
- package/apps/web/dist/assets/splunk-BC2Px7Mm.js +1 -0
- package/apps/web/dist/assets/sql-fa1gAeRF.js +1 -0
- package/apps/web/dist/assets/ssh-config-BgfXC-Er.js +1 -0
- package/apps/web/dist/assets/stata-DgTOpGhg.js +1 -0
- package/apps/web/dist/assets/stylus-B6D30XZt.js +1 -0
- package/apps/web/dist/assets/surrealql-DVqEkJeu.js +1 -0
- package/apps/web/dist/assets/svelte-CyQ5sU9I.js +1 -0
- package/apps/web/dist/assets/swift-CyEgAFGc.js +1 -0
- package/apps/web/dist/assets/synthwave-84-nFMaYfgc.js +1 -0
- package/apps/web/dist/assets/system-verilog-Dh5ihWbf.js +1 -0
- package/apps/web/dist/assets/systemd-BxMlprV5.js +1 -0
- package/apps/web/dist/assets/talonscript-CohzipZa.js +1 -0
- package/apps/web/dist/assets/tasl-DMoTqEGO.js +1 -0
- package/apps/web/dist/assets/tcl-CZd0xW_V.js +1 -0
- package/apps/web/dist/assets/templ-DrztMbAf.js +1 -0
- package/apps/web/dist/assets/terraform-DswuEJGm.js +1 -0
- package/apps/web/dist/assets/tex-NAwM8Kkh.js +1 -0
- package/apps/web/dist/assets/tokyo-night-oM2G3aXe.js +1 -0
- package/apps/web/dist/assets/toml-CcmNWLt0.js +1 -0
- package/apps/web/dist/assets/ts-tags-DX96dDxh.js +1 -0
- package/apps/web/dist/assets/tsv-sltzmVWM.js +1 -0
- package/apps/web/dist/assets/tsx-D3PnhDHK.js +1 -0
- package/apps/web/dist/assets/turtle-ByJddavk.js +1 -0
- package/apps/web/dist/assets/twig-FG0P9evf.js +1 -0
- package/apps/web/dist/assets/typescript-Crqeuw0P.js +1 -0
- package/apps/web/dist/assets/typespec-BGhR2SqG.js +1 -0
- package/apps/web/dist/assets/typst-CO_2MFRr.js +1 -0
- package/apps/web/dist/assets/v-DBj4K9d_.js +1 -0
- package/apps/web/dist/assets/vala-zf12oZj6.js +1 -0
- package/apps/web/dist/assets/vb-DOwzaHZ0.js +1 -0
- package/apps/web/dist/assets/verilog-B2gwz-sJ.js +1 -0
- package/apps/web/dist/assets/vesper-DdrHHSXu.js +1 -0
- package/apps/web/dist/assets/vhdl-BroJfC0k.js +1 -0
- package/apps/web/dist/assets/viml-DvXPmvsu.js +1 -0
- package/apps/web/dist/assets/vitesse-black-fwtXNY1n.js +1 -0
- package/apps/web/dist/assets/vitesse-dark-BZCL-v6S.js +1 -0
- package/apps/web/dist/assets/vitesse-light-VbXTXTou.js +1 -0
- package/apps/web/dist/assets/vue-fTNrS0Q3.js +1 -0
- package/apps/web/dist/assets/vue-html-E0ptmXwc.js +1 -0
- package/apps/web/dist/assets/vue-vine-C34_rJIu.js +1 -0
- package/apps/web/dist/assets/vyper-CgoNMtux.js +1 -0
- package/apps/web/dist/assets/wasm-BnjxR4X6.js +1 -0
- package/apps/web/dist/assets/wasm-ByWQv1Qj.js +1 -0
- package/apps/web/dist/assets/wenyan-C8pVoKbM.js +1 -0
- package/apps/web/dist/assets/wgsl-BsKzXJz4.js +1 -0
- package/apps/web/dist/assets/wikitext-ClFFjSW2.js +1 -0
- package/apps/web/dist/assets/wit-DdvCle-K.js +1 -0
- package/apps/web/dist/assets/wolfram-DLL8P-h_.js +1 -0
- package/apps/web/dist/assets/xml-BB9WbMMU.js +1 -0
- package/apps/web/dist/assets/xsl-B3w2P7LL.js +1 -0
- package/apps/web/dist/assets/yaml-BKGRKqBA.js +1 -0
- package/apps/web/dist/assets/zenscript-BnlCZFoB.js +1 -0
- package/apps/web/dist/assets/zig-CMLA9XwU.js +1 -0
- package/apps/web/dist/index.html +17 -0
- package/apps/web/dist/sw.js +81 -0
- package/bin/offsite.js +2 -0
- package/package.json +19 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { git } from './git.js';
|
|
5
|
+
import { home } from './storage.js';
|
|
6
|
+
const FILE_LIMIT = 20_000;
|
|
7
|
+
const skipped = new Set(['node_modules', '.git', 'dist', 'target', '.next']);
|
|
8
|
+
export async function listFiles(cwd) {
|
|
9
|
+
try {
|
|
10
|
+
const { stdout } = await git(cwd, [
|
|
11
|
+
'ls-files',
|
|
12
|
+
'--cached',
|
|
13
|
+
'--others',
|
|
14
|
+
'--exclude-standard',
|
|
15
|
+
]);
|
|
16
|
+
return stdout.split('\n').filter(Boolean).slice(0, FILE_LIMIT);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return walk(cwd);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function saveUpload(name, data) {
|
|
23
|
+
const dir = path.join(home, 'uploads', randomUUID());
|
|
24
|
+
mkdirSync(dir, { recursive: true });
|
|
25
|
+
const file = path.join(dir, path.basename(name));
|
|
26
|
+
writeFileSync(file, data);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
function walk(root) {
|
|
30
|
+
const files = [];
|
|
31
|
+
const pending = [''];
|
|
32
|
+
while (pending.length > 0 && files.length < FILE_LIMIT) {
|
|
33
|
+
const dir = pending.pop() ?? '';
|
|
34
|
+
let entries;
|
|
35
|
+
try {
|
|
36
|
+
entries = readdirSync(path.join(root, dir), { withFileTypes: true });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
const relative = dir === '' ? entry.name : `${dir}/${entry.name}`;
|
|
43
|
+
if (entry.isDirectory() && !skipped.has(entry.name))
|
|
44
|
+
pending.push(relative);
|
|
45
|
+
if (entry.isFile())
|
|
46
|
+
files.push(relative);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return files;
|
|
50
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
6
|
+
import { claudeOptions } from './claude.js';
|
|
7
|
+
const DIFF_LIMIT = 80_000;
|
|
8
|
+
const UNTRACKED_LIMIT = 100;
|
|
9
|
+
const NEW_FILE_LIMIT = 256 * 1024;
|
|
10
|
+
export async function gitStatus(cwd) {
|
|
11
|
+
let output;
|
|
12
|
+
try {
|
|
13
|
+
output = await git(cwd, ['status', '--porcelain=v2', '--branch']);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const status = {
|
|
19
|
+
branch: null,
|
|
20
|
+
upstream: null,
|
|
21
|
+
ahead: 0,
|
|
22
|
+
behind: 0,
|
|
23
|
+
changed: 0,
|
|
24
|
+
};
|
|
25
|
+
for (const line of output.stdout.split('\n').filter(Boolean)) {
|
|
26
|
+
const [marker, key, ...rest] = line.split(' ');
|
|
27
|
+
if (marker !== '#')
|
|
28
|
+
status.changed++;
|
|
29
|
+
else if (key === 'branch.head')
|
|
30
|
+
status.branch = rest[0] === '(detached)' ? null : rest[0];
|
|
31
|
+
else if (key === 'branch.upstream')
|
|
32
|
+
status.upstream = rest[0];
|
|
33
|
+
else if (key === 'branch.ab') {
|
|
34
|
+
status.ahead = Number(rest[0]);
|
|
35
|
+
status.behind = -Number(rest[1]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return status;
|
|
39
|
+
}
|
|
40
|
+
export async function commit(cwd, message) {
|
|
41
|
+
if (message.trim() === '')
|
|
42
|
+
throw new Error('Write a commit message first');
|
|
43
|
+
await git(cwd, ['add', '--all']);
|
|
44
|
+
await git(cwd, ['commit', '--message', message]);
|
|
45
|
+
return gitStatus(cwd);
|
|
46
|
+
}
|
|
47
|
+
export async function push(cwd) {
|
|
48
|
+
const status = await gitStatus(cwd);
|
|
49
|
+
if (status === null)
|
|
50
|
+
throw new Error(`${cwd} is not a git repository`);
|
|
51
|
+
if (status.upstream === null)
|
|
52
|
+
await git(cwd, ['push', '--set-upstream', 'origin', 'HEAD']);
|
|
53
|
+
else
|
|
54
|
+
await git(cwd, ['push']);
|
|
55
|
+
return gitStatus(cwd);
|
|
56
|
+
}
|
|
57
|
+
export async function createPullRequest(cwd) {
|
|
58
|
+
const { stdout } = await promisify(execFile)('gh', ['pr', 'create', '--fill'], { cwd });
|
|
59
|
+
const url = stdout.trim().split('\n').at(-1);
|
|
60
|
+
if (url === undefined)
|
|
61
|
+
throw new Error('gh did not return a pull request URL');
|
|
62
|
+
return { url };
|
|
63
|
+
}
|
|
64
|
+
export async function suggestCommitMessage(accountId, cwd) {
|
|
65
|
+
const diff = (await workingDiff(cwd)).slice(0, DIFF_LIMIT);
|
|
66
|
+
if (diff === '')
|
|
67
|
+
throw new Error('There is nothing to commit');
|
|
68
|
+
const conversation = query({
|
|
69
|
+
prompt: `Write a git commit message for this diff. Reply with only the message: a short summary line, optionally followed by a blank line and a brief body.\n\n${diff}`,
|
|
70
|
+
options: {
|
|
71
|
+
...claudeOptions(accountId, cwd),
|
|
72
|
+
systemPrompt: 'You write concise git commit messages.',
|
|
73
|
+
tools: [],
|
|
74
|
+
model: 'haiku',
|
|
75
|
+
maxTurns: 1,
|
|
76
|
+
persistSession: false,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
for await (const message of conversation) {
|
|
80
|
+
if (message.type !== 'result')
|
|
81
|
+
continue;
|
|
82
|
+
if (message.subtype !== 'success')
|
|
83
|
+
throw new Error(message.errors.join('\n'));
|
|
84
|
+
if (message.is_error)
|
|
85
|
+
throw new Error(message.result);
|
|
86
|
+
return { message: message.result.trim() };
|
|
87
|
+
}
|
|
88
|
+
throw new Error('Claude did not reply');
|
|
89
|
+
}
|
|
90
|
+
export async function workingDiff(cwd) {
|
|
91
|
+
try {
|
|
92
|
+
await git(cwd, ['rev-parse', '--is-inside-work-tree']);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new Error(`${cwd} is not a git repository`);
|
|
96
|
+
}
|
|
97
|
+
const tracked = await git(cwd, [
|
|
98
|
+
'diff',
|
|
99
|
+
'HEAD',
|
|
100
|
+
'--no-color',
|
|
101
|
+
'--no-ext-diff',
|
|
102
|
+
]);
|
|
103
|
+
const untracked = await git(cwd, [
|
|
104
|
+
'ls-files',
|
|
105
|
+
'--others',
|
|
106
|
+
'--exclude-standard',
|
|
107
|
+
]);
|
|
108
|
+
const added = untracked.stdout
|
|
109
|
+
.split('\n')
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.slice(0, UNTRACKED_LIMIT)
|
|
112
|
+
.map((file) => newFilePatch(cwd, file));
|
|
113
|
+
return [tracked.stdout, ...added].join('');
|
|
114
|
+
}
|
|
115
|
+
export function git(cwd, args) {
|
|
116
|
+
return promisify(execFile)('git', args, {
|
|
117
|
+
cwd,
|
|
118
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function newFilePatch(cwd, file) {
|
|
122
|
+
const header = `diff --git a/${file} b/${file}\nnew file\n--- /dev/null\n+++ b/${file}\n`;
|
|
123
|
+
const full = path.join(cwd, file);
|
|
124
|
+
if (statSync(full).size > NEW_FILE_LIMIT)
|
|
125
|
+
return `${header}Binary or large file\n`;
|
|
126
|
+
const content = readFileSync(full, 'utf8');
|
|
127
|
+
if (content.includes('\0'))
|
|
128
|
+
return `${header}Binary or large file\n`;
|
|
129
|
+
const lines = content.split('\n');
|
|
130
|
+
if (lines.at(-1) === '')
|
|
131
|
+
lines.pop();
|
|
132
|
+
return `${header}@@ -0,0 +1,${lines.length} @@\n${lines.map((line) => `+${line}\n`).join('')}`;
|
|
133
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { getSessionMessages, getSubagentMessages, } from '@anthropic-ai/claude-agent-sdk';
|
|
5
|
+
import { contextTokens, toMessage } from './content.js';
|
|
6
|
+
import { runs } from './run.js';
|
|
7
|
+
const projectsDir = path.join(os.homedir(), '.claude', 'projects');
|
|
8
|
+
async function sessionEntries(sessionId) {
|
|
9
|
+
for (const dir of await readdir(projectsDir)) {
|
|
10
|
+
let text;
|
|
11
|
+
try {
|
|
12
|
+
text = await readFile(path.join(projectsDir, dir, `${sessionId}.jsonl`), 'utf8');
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code === 'ENOENT')
|
|
16
|
+
continue;
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return text.split('\n').flatMap((line) => {
|
|
20
|
+
const entry = parseLine(line);
|
|
21
|
+
return entry !== null && typeof entry.type === 'string'
|
|
22
|
+
? [{ ...entry, type: entry.type }]
|
|
23
|
+
: [];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
function messageTimes(entries) {
|
|
29
|
+
const times = new Map();
|
|
30
|
+
for (const entry of entries)
|
|
31
|
+
if (typeof entry.uuid === 'string' && typeof entry.timestamp === 'string')
|
|
32
|
+
times.set(entry.uuid, Date.parse(entry.timestamp));
|
|
33
|
+
return times;
|
|
34
|
+
}
|
|
35
|
+
function compactedBefore(entries, uuid) {
|
|
36
|
+
if (uuid === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
const start = entries.findIndex((entry) => entry.uuid === uuid);
|
|
39
|
+
const index = entries.findLastIndex((entry, position) => position < start &&
|
|
40
|
+
entry.type === 'system' &&
|
|
41
|
+
entry.subtype === 'compact_boundary');
|
|
42
|
+
return index < 0 ? null : index;
|
|
43
|
+
}
|
|
44
|
+
function parseLine(line) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(line);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function mainMessages(disk, times) {
|
|
53
|
+
return disk.flatMap((item) => item.type === 'system' || item.parent_tool_use_id !== null
|
|
54
|
+
? []
|
|
55
|
+
: [toMessage(item.type, item, times.get(item.uuid) ?? null)]);
|
|
56
|
+
}
|
|
57
|
+
export async function history(sessionId, cwd) {
|
|
58
|
+
const run = runs.get(sessionId);
|
|
59
|
+
const [disk, entries] = await Promise.all([
|
|
60
|
+
getSessionMessages(sessionId, { dir: cwd }),
|
|
61
|
+
sessionEntries(sessionId),
|
|
62
|
+
]);
|
|
63
|
+
const resumeAt = run?.resumeAt ?? null;
|
|
64
|
+
const kept = resumeAt === null
|
|
65
|
+
? disk
|
|
66
|
+
: disk.slice(0, disk.findIndex((item) => item.uuid === resumeAt) + 1);
|
|
67
|
+
const messages = mainMessages(kept, messageTimes(entries));
|
|
68
|
+
messages.push(...(await subagentMessages(sessionId, cwd, messages)));
|
|
69
|
+
const seen = new Set(messages.map((item) => item.uuid));
|
|
70
|
+
const last = kept.findLast((item) => item.type === 'assistant' && item.parent_tool_use_id === null);
|
|
71
|
+
const tokens = last === undefined ? null : contextTokens(last.message);
|
|
72
|
+
return {
|
|
73
|
+
type: 'history',
|
|
74
|
+
sessionId,
|
|
75
|
+
messages: [
|
|
76
|
+
...messages,
|
|
77
|
+
...(run?.messages.filter((item) => !seen.has(item.uuid)) ?? []),
|
|
78
|
+
],
|
|
79
|
+
requests: [...(run?.pending.values() ?? [])].map((item) => item.request),
|
|
80
|
+
queue: run?.queue ?? [],
|
|
81
|
+
settings: run?.settings ?? null,
|
|
82
|
+
context: run?.context ??
|
|
83
|
+
(tokens === null
|
|
84
|
+
? null
|
|
85
|
+
: { tokens, window: null, model: null, categories: [], sections: [] }),
|
|
86
|
+
before: compactedBefore(entries, disk[0]?.uuid),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export async function earlier(sessionId, cwd, before) {
|
|
90
|
+
const entries = await sessionEntries(sessionId);
|
|
91
|
+
const kept = entries.slice(0, before);
|
|
92
|
+
const disk = await getSessionMessages(sessionId, {
|
|
93
|
+
sessionStore: { append: () => Promise.resolve(), load: async () => kept },
|
|
94
|
+
});
|
|
95
|
+
const messages = mainMessages(disk, messageTimes(entries));
|
|
96
|
+
messages.push(...(await subagentMessages(sessionId, cwd, messages)));
|
|
97
|
+
messages.push({
|
|
98
|
+
type: 'notice',
|
|
99
|
+
uuid: `compacted:${before}`,
|
|
100
|
+
time: null,
|
|
101
|
+
text: 'Conversation compacted',
|
|
102
|
+
isError: false,
|
|
103
|
+
});
|
|
104
|
+
return { messages, before: compactedBefore(entries, disk[0]?.uuid) };
|
|
105
|
+
}
|
|
106
|
+
async function subagentMessages(sessionId, cwd, messages) {
|
|
107
|
+
const agents = new Set(messages.flatMap((message) => message.type === 'assistant'
|
|
108
|
+
? message.content.flatMap((block) => block.type === 'tool_use' &&
|
|
109
|
+
(block.name === 'Agent' || block.name === 'Task')
|
|
110
|
+
? [block.id]
|
|
111
|
+
: [])
|
|
112
|
+
: []));
|
|
113
|
+
const launches = messages.flatMap((message) => message.type === 'user'
|
|
114
|
+
? message.content.flatMap((block) => {
|
|
115
|
+
if (block.type !== 'tool_result' || !agents.has(block.toolUseId))
|
|
116
|
+
return [];
|
|
117
|
+
const agentId = /agentId: (\w+)/.exec(block.content
|
|
118
|
+
.map((item) => (item.type === 'text' ? item.text : ''))
|
|
119
|
+
.join('\n'))?.[1];
|
|
120
|
+
return agentId === undefined
|
|
121
|
+
? []
|
|
122
|
+
: [{ agentId, parent: block.toolUseId }];
|
|
123
|
+
})
|
|
124
|
+
: []);
|
|
125
|
+
const loaded = await Promise.all(launches.map(async (launch) => {
|
|
126
|
+
const disk = await getSubagentMessages(sessionId, launch.agentId, {
|
|
127
|
+
dir: cwd,
|
|
128
|
+
});
|
|
129
|
+
const items = disk.flatMap((item) => item.type === 'system'
|
|
130
|
+
? []
|
|
131
|
+
: [
|
|
132
|
+
toMessage(item.type, { ...item, parent_tool_use_id: launch.parent }, null),
|
|
133
|
+
]);
|
|
134
|
+
return [...items, ...(await subagentMessages(sessionId, cwd, items))];
|
|
135
|
+
}));
|
|
136
|
+
return loaded.flat();
|
|
137
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const clients = new Set();
|
|
2
|
+
export function publish(sessionId, event) {
|
|
3
|
+
for (const client of clients)
|
|
4
|
+
if (client.sessionId === sessionId)
|
|
5
|
+
client.send(event);
|
|
6
|
+
}
|
|
7
|
+
export function broadcast(event) {
|
|
8
|
+
for (const client of clients)
|
|
9
|
+
client.send(event);
|
|
10
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createReadStream, existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { WebSocketServer } from 'ws';
|
|
5
|
+
import { args } from './args.js';
|
|
6
|
+
import { findClaude } from './claude.js';
|
|
7
|
+
import { startPush } from './push.js';
|
|
8
|
+
import { stopAll } from './runs.js';
|
|
9
|
+
import { connectClient } from './socket.js';
|
|
10
|
+
const contentTypes = {
|
|
11
|
+
'.html': 'text/html; charset=utf-8',
|
|
12
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
13
|
+
'.css': 'text/css; charset=utf-8',
|
|
14
|
+
'.svg': 'image/svg+xml',
|
|
15
|
+
'.png': 'image/png',
|
|
16
|
+
'.ico': 'image/x-icon',
|
|
17
|
+
'.json': 'application/json',
|
|
18
|
+
'.webmanifest': 'application/manifest+json',
|
|
19
|
+
'.woff2': 'font/woff2',
|
|
20
|
+
};
|
|
21
|
+
const port = Number(args.port);
|
|
22
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
23
|
+
console.error(`invalid port ${args.port}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
if (findClaude() === null) {
|
|
27
|
+
console.error('could not find claude on PATH; install Claude Code first');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const publicDir = path.join(import.meta.dirname, '..', '..', 'web', 'dist');
|
|
31
|
+
const server = createServer((request, response) => {
|
|
32
|
+
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
33
|
+
serveFile(url.pathname, response);
|
|
34
|
+
});
|
|
35
|
+
const sockets = new WebSocketServer({ noServer: true });
|
|
36
|
+
server.on('upgrade', (request, socket, head) => {
|
|
37
|
+
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
38
|
+
if (url.pathname === '/ws')
|
|
39
|
+
sockets.handleUpgrade(request, socket, head, connectClient);
|
|
40
|
+
else
|
|
41
|
+
socket.destroy();
|
|
42
|
+
});
|
|
43
|
+
server.listen(port, args.host, () => {
|
|
44
|
+
startPush(`${args.host}:${port}`);
|
|
45
|
+
console.log(`offsite is running at http://${args.host}:${port}`);
|
|
46
|
+
});
|
|
47
|
+
process.on('SIGINT', () => {
|
|
48
|
+
stopAll();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
function serveFile(pathname, response) {
|
|
52
|
+
const requested = path.join(publicDir, path.normalize(pathname));
|
|
53
|
+
const file = requested.startsWith(publicDir + path.sep) &&
|
|
54
|
+
statSync(requested, { throwIfNoEntry: false })?.isFile()
|
|
55
|
+
? requested
|
|
56
|
+
: path.join(publicDir, 'index.html');
|
|
57
|
+
if (!existsSync(file)) {
|
|
58
|
+
response.statusCode = 404;
|
|
59
|
+
response.end('web app not built; run pnpm build');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
response.setHeader('content-type', contentTypes[path.extname(file)] ?? 'application/octet-stream');
|
|
63
|
+
createReadStream(file).pipe(response);
|
|
64
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { db } from './db.js';
|
|
5
|
+
import { broadcast } from './hub.js';
|
|
6
|
+
const LOGO_TYPES = [
|
|
7
|
+
'image/png',
|
|
8
|
+
'image/jpeg',
|
|
9
|
+
'image/gif',
|
|
10
|
+
'image/webp',
|
|
11
|
+
'image/svg+xml',
|
|
12
|
+
'image/x-icon',
|
|
13
|
+
'image/vnd.microsoft.icon',
|
|
14
|
+
];
|
|
15
|
+
const LOGO_LIMIT = 512 * 1024;
|
|
16
|
+
export function projects() {
|
|
17
|
+
return db
|
|
18
|
+
.prepare('SELECT path, name, logo FROM projects')
|
|
19
|
+
.all()
|
|
20
|
+
.map(toProject);
|
|
21
|
+
}
|
|
22
|
+
export async function addProject(input) {
|
|
23
|
+
const folder = path.resolve(expandHome(input.trim()));
|
|
24
|
+
if (!(await stat(folder)).isDirectory())
|
|
25
|
+
throw new Error(`${folder} is not a folder`);
|
|
26
|
+
db.prepare('INSERT OR IGNORE INTO projects (path, name, logo) VALUES (?, ?, NULL)').run(folder, path.basename(folder) || folder);
|
|
27
|
+
publish();
|
|
28
|
+
const project = projects().find((item) => item.path === folder);
|
|
29
|
+
if (project === undefined)
|
|
30
|
+
throw new Error(`Could not add ${folder}`);
|
|
31
|
+
return project;
|
|
32
|
+
}
|
|
33
|
+
export function updateProject(folder, patch) {
|
|
34
|
+
if (patch.name !== undefined) {
|
|
35
|
+
const name = patch.name.trim();
|
|
36
|
+
if (name === '')
|
|
37
|
+
throw new Error('Project name cannot be empty');
|
|
38
|
+
db.prepare('UPDATE projects SET name = ? WHERE path = ?').run(name, folder);
|
|
39
|
+
}
|
|
40
|
+
if (patch.logo !== undefined) {
|
|
41
|
+
if (patch.logo !== null)
|
|
42
|
+
checkLogo(patch.logo);
|
|
43
|
+
db.prepare('UPDATE projects SET logo = ? WHERE path = ?').run(patch.logo, folder);
|
|
44
|
+
}
|
|
45
|
+
publish();
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
export function removeProject(folder) {
|
|
49
|
+
db.prepare('DELETE FROM projects WHERE path = ?').run(folder);
|
|
50
|
+
publish();
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
export async function directories(input) {
|
|
54
|
+
const folder = path.resolve(expandHome(input.trim()));
|
|
55
|
+
const entries = await readdir(folder, { withFileTypes: true });
|
|
56
|
+
const parent = path.dirname(folder);
|
|
57
|
+
return {
|
|
58
|
+
path: folder,
|
|
59
|
+
parent: parent === folder ? null : parent,
|
|
60
|
+
directories: entries
|
|
61
|
+
.filter((entry) => entry.isDirectory())
|
|
62
|
+
.map((entry) => ({
|
|
63
|
+
name: entry.name,
|
|
64
|
+
path: path.join(folder, entry.name),
|
|
65
|
+
}))
|
|
66
|
+
.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function publish() {
|
|
70
|
+
broadcast({ type: 'projects', projects: projects() });
|
|
71
|
+
}
|
|
72
|
+
function toProject(row) {
|
|
73
|
+
if (typeof row.path !== 'string' ||
|
|
74
|
+
typeof row.name !== 'string' ||
|
|
75
|
+
(typeof row.logo !== 'string' && row.logo !== null))
|
|
76
|
+
throw new Error('The projects table has an unexpected row');
|
|
77
|
+
return { path: row.path, name: row.name, logo: row.logo };
|
|
78
|
+
}
|
|
79
|
+
function checkLogo(logo) {
|
|
80
|
+
const type = /^data:([^;,]+);base64,/.exec(logo)?.[1];
|
|
81
|
+
if (type === undefined || !LOGO_TYPES.includes(type))
|
|
82
|
+
throw new Error('Use a PNG, JPEG, GIF, WebP, SVG or ICO image');
|
|
83
|
+
if (logo.length > LOGO_LIMIT)
|
|
84
|
+
throw new Error('Use an image smaller than 384 KB');
|
|
85
|
+
}
|
|
86
|
+
function expandHome(input) {
|
|
87
|
+
if (input === '~')
|
|
88
|
+
return os.homedir();
|
|
89
|
+
if (input.startsWith('~/'))
|
|
90
|
+
return path.join(os.homedir(), input.slice(2));
|
|
91
|
+
return input;
|
|
92
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const FRAME_INPUT = 0;
|
|
2
|
+
export const FRAME_REPLY = 1;
|
|
3
|
+
export const FRAME_OUTPUT = 2;
|
|
4
|
+
export const FRAME_REPLAY = 3;
|
|
5
|
+
export function encodeFrame(kind, id, data) {
|
|
6
|
+
const frame = new Uint8Array(5 + data.length);
|
|
7
|
+
frame[0] = kind;
|
|
8
|
+
new DataView(frame.buffer).setUint32(1, id);
|
|
9
|
+
frame.set(data, 5);
|
|
10
|
+
return frame;
|
|
11
|
+
}
|
|
12
|
+
export function decodeFrame(frame) {
|
|
13
|
+
if (frame.length < 5)
|
|
14
|
+
throw new Error('terminal frame is too short');
|
|
15
|
+
return {
|
|
16
|
+
kind: frame[0],
|
|
17
|
+
id: new DataView(frame.buffer, frame.byteOffset, frame.byteLength).getUint32(1),
|
|
18
|
+
data: frame.subarray(5),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { renameSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import webPush from 'web-push';
|
|
5
|
+
import { home, readJson, writeJson } from './storage.js';
|
|
6
|
+
const pushFile = path.join(home, 'push.json');
|
|
7
|
+
const TITLE_LIMIT = 100;
|
|
8
|
+
const BODY_LIMIT = 500;
|
|
9
|
+
const TIME_TO_LIVE = 15 * 60;
|
|
10
|
+
const SEND_TIMEOUT = 10_000;
|
|
11
|
+
const SUBJECT = 'https://github.com/NazmusSayad/offsite';
|
|
12
|
+
let server = '';
|
|
13
|
+
let active = false;
|
|
14
|
+
export function startPush(address) {
|
|
15
|
+
server = address;
|
|
16
|
+
try {
|
|
17
|
+
const store = readJson('push.json');
|
|
18
|
+
if (store !== null)
|
|
19
|
+
track(store);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.warn(`push notifications are off until a browser turns them on again, could not read ${pushFile}: ${error}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function pushActive() {
|
|
26
|
+
return active;
|
|
27
|
+
}
|
|
28
|
+
export function pushKey() {
|
|
29
|
+
return { publicKey: read().publicKey };
|
|
30
|
+
}
|
|
31
|
+
export function subscribe(subscription) {
|
|
32
|
+
const endpoint = new URL(subscription.endpoint);
|
|
33
|
+
if (endpoint.protocol !== 'https:')
|
|
34
|
+
throw new Error('the endpoint must be an https URL');
|
|
35
|
+
update((store) => {
|
|
36
|
+
store.subscriptions = store.subscriptions.filter((existing) => existing.endpoint !== subscription.endpoint);
|
|
37
|
+
store.subscriptions.push({
|
|
38
|
+
endpoint: subscription.endpoint,
|
|
39
|
+
keys: { p256dh: subscription.keys.p256dh, auth: subscription.keys.auth },
|
|
40
|
+
server,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
console.log('a browser subscribed to push notifications');
|
|
44
|
+
}
|
|
45
|
+
export function unsubscribe(endpoint) {
|
|
46
|
+
update((store) => {
|
|
47
|
+
store.subscriptions = store.subscriptions.filter((existing) => existing.endpoint !== endpoint);
|
|
48
|
+
});
|
|
49
|
+
console.log('a browser unsubscribed from push notifications');
|
|
50
|
+
}
|
|
51
|
+
export async function sendPush(message) {
|
|
52
|
+
let store;
|
|
53
|
+
try {
|
|
54
|
+
store = read();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error(`could not read push subscriptions: ${error}`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const subscriptions = store.subscriptions.filter(ours);
|
|
61
|
+
if (subscriptions.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
const payload = JSON.stringify({
|
|
64
|
+
...message,
|
|
65
|
+
title: [...message.title].slice(0, TITLE_LIMIT).join(''),
|
|
66
|
+
body: [...message.body].slice(0, BODY_LIMIT).join(''),
|
|
67
|
+
});
|
|
68
|
+
const gone = [];
|
|
69
|
+
await Promise.all(subscriptions.map(async (subscription) => {
|
|
70
|
+
try {
|
|
71
|
+
await webPush.sendNotification(subscription, payload, {
|
|
72
|
+
vapidDetails: {
|
|
73
|
+
subject: SUBJECT,
|
|
74
|
+
publicKey: store.publicKey,
|
|
75
|
+
privateKey: store.privateKey,
|
|
76
|
+
},
|
|
77
|
+
TTL: TIME_TO_LIVE,
|
|
78
|
+
urgency: 'high',
|
|
79
|
+
timeout: SEND_TIMEOUT,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const status = error.statusCode;
|
|
84
|
+
if (status !== undefined && [401, 403, 404, 410].includes(status)) {
|
|
85
|
+
console.log(`push subscription ${subscription.endpoint} is gone or was made for another key, removing it`);
|
|
86
|
+
gone.push(subscription.endpoint);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
console.warn(`could not send a push to ${subscription.endpoint}: ${error}`);
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
if (gone.length === 0)
|
|
93
|
+
return;
|
|
94
|
+
try {
|
|
95
|
+
update((current) => {
|
|
96
|
+
current.subscriptions = current.subscriptions.filter((subscription) => !gone.includes(subscription.endpoint));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error(`could not remove gone push subscriptions: ${error}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function ours(subscription) {
|
|
104
|
+
return subscription.server === server;
|
|
105
|
+
}
|
|
106
|
+
function track(store) {
|
|
107
|
+
active = store.subscriptions.some(ours);
|
|
108
|
+
}
|
|
109
|
+
function load() {
|
|
110
|
+
let store;
|
|
111
|
+
try {
|
|
112
|
+
store = readJson('push.json');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!(error instanceof SyntaxError))
|
|
116
|
+
throw error;
|
|
117
|
+
return replaceCorrupt(error);
|
|
118
|
+
}
|
|
119
|
+
if (store === null)
|
|
120
|
+
return create();
|
|
121
|
+
if (typeof store.publicKey !== 'string' ||
|
|
122
|
+
typeof store.privateKey !== 'string' ||
|
|
123
|
+
!Array.isArray(store.subscriptions))
|
|
124
|
+
return replaceCorrupt(new Error('it is missing its keys or subscriptions'));
|
|
125
|
+
return store;
|
|
126
|
+
}
|
|
127
|
+
function replaceCorrupt(error) {
|
|
128
|
+
const aside = `${pushFile}.corrupt-${randomUUID()}`;
|
|
129
|
+
renameSync(pushFile, aside);
|
|
130
|
+
console.warn(`${pushFile} is corrupt, moved it to ${aside} and created a new one: ${error}`);
|
|
131
|
+
return create();
|
|
132
|
+
}
|
|
133
|
+
function create() {
|
|
134
|
+
const keys = webPush.generateVAPIDKeys();
|
|
135
|
+
const store = { ...keys, subscriptions: [] };
|
|
136
|
+
save(store);
|
|
137
|
+
return store;
|
|
138
|
+
}
|
|
139
|
+
function save(store) {
|
|
140
|
+
writeJson('push.json', store);
|
|
141
|
+
}
|
|
142
|
+
function read() {
|
|
143
|
+
const store = load();
|
|
144
|
+
track(store);
|
|
145
|
+
return store;
|
|
146
|
+
}
|
|
147
|
+
function update(change) {
|
|
148
|
+
const store = load();
|
|
149
|
+
change(store);
|
|
150
|
+
save(store);
|
|
151
|
+
track(store);
|
|
152
|
+
}
|