@sunshinelife83/hearth 1.0.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/LICENSE +21 -0
- package/README.md +323 -0
- package/bin/hearth-agentd.js +4 -0
- package/bin/hearth.js +4 -0
- package/bin/run-entrypoint.js +20 -0
- package/dist/agent-tools.js +738 -0
- package/dist/app-version.js +16 -0
- package/dist/apply-patch.js +402 -0
- package/dist/artifact-error.js +8 -0
- package/dist/artifact-tools.js +377 -0
- package/dist/cli-workspace.js +36 -0
- package/dist/cli.js +1086 -0
- package/dist/config-migration.js +82 -0
- package/dist/config-schema.js +136 -0
- package/dist/config.js +115 -0
- package/dist/context/context-tools.js +150 -0
- package/dist/context/repo-map.js +102 -0
- package/dist/dashboard/app.js +226 -0
- package/dist/dashboard/index.html +45 -0
- package/dist/dashboard/landing.html +57 -0
- package/dist/dashboard/styles.css +23 -0
- package/dist/dashboard.js +271 -0
- package/dist/db/client.js +29 -0
- package/dist/db/migrations.js +262 -0
- package/dist/db/schema.js +85 -0
- package/dist/device-tokens.js +61 -0
- package/dist/git-worktrees.js +134 -0
- package/dist/git.js +41 -0
- package/dist/incoming-artifacts.js +378 -0
- package/dist/local-agent-acp.js +768 -0
- package/dist/local-agent-adapters.js +20 -0
- package/dist/local-agent-availability.js +92 -0
- package/dist/local-agent-catalog.js +51 -0
- package/dist/local-agent-claude.js +334 -0
- package/dist/local-agent-client.js +519 -0
- package/dist/local-agent-codex.js +532 -0
- package/dist/local-agent-config.js +34 -0
- package/dist/local-agent-daemon-lifecycle.js +195 -0
- package/dist/local-agent-daemon-main.js +86 -0
- package/dist/local-agent-daemon-protocol.js +302 -0
- package/dist/local-agent-daemon.js +407 -0
- package/dist/local-agent-errors.js +378 -0
- package/dist/local-agent-grok.js +202 -0
- package/dist/local-agent-manager.js +715 -0
- package/dist/local-agent-opencode.js +463 -0
- package/dist/local-agent-path.js +24 -0
- package/dist/local-agent-pi-sandbox.js +472 -0
- package/dist/local-agent-pi.js +298 -0
- package/dist/local-agent-presentation.js +104 -0
- package/dist/local-agent-profiles.js +127 -0
- package/dist/local-agent-runtime-pool.js +481 -0
- package/dist/local-agent-runtime.js +1 -0
- package/dist/local-agent-store.js +193 -0
- package/dist/local-agent-targets.js +97 -0
- package/dist/logger.js +97 -0
- package/dist/machine-id.js +35 -0
- package/dist/mcp-modern-server.js +65 -0
- package/dist/oauth-provider.js +331 -0
- package/dist/oauth-store.js +144 -0
- package/dist/onboarding.js +35 -0
- package/dist/orchestration/brief.js +70 -0
- package/dist/orchestration/lanes.js +145 -0
- package/dist/orchestration/result.js +46 -0
- package/dist/orchestration/scope.js +61 -0
- package/dist/pi-tools.js +58 -0
- package/dist/policy/command-policy.js +104 -0
- package/dist/policy/env-allowlist.js +96 -0
- package/dist/policy/sandbox.js +68 -0
- package/dist/policy/workspace-profiles.js +47 -0
- package/dist/process-journal.js +116 -0
- package/dist/process-platform.js +49 -0
- package/dist/process-sessions.js +388 -0
- package/dist/rate-limit.js +77 -0
- package/dist/request-meta.js +9 -0
- package/dist/review-checkpoints.js +349 -0
- package/dist/roots.js +37 -0
- package/dist/server-shutdown.js +12 -0
- package/dist/server.js +980 -0
- package/dist/skills.js +84 -0
- package/dist/snapshot-manager.js +123 -0
- package/dist/stdio-server.js +80 -0
- package/dist/task-store.js +203 -0
- package/dist/task-tools.js +455 -0
- package/dist/tool-surfaces/claude.js +220 -0
- package/dist/tool-surfaces/codex.js +255 -0
- package/dist/tool-surfaces/index.js +15 -0
- package/dist/tool-surfaces/shared.js +228 -0
- package/dist/tool-surfaces/types.js +27 -0
- package/dist/ui/.vite/manifest.json +2544 -0
- package/dist/ui/assets/abap-CLvhMVsD.js +1 -0
- package/dist/ui/assets/actionscript-3--17pq3dv.js +1 -0
- package/dist/ui/assets/ada-C5qYipkI.js +1 -0
- package/dist/ui/assets/andromeeda-vGVdxbeo.js +1 -0
- package/dist/ui/assets/angular-html-DrbO3_Xe.js +1 -0
- package/dist/ui/assets/angular-ts-CmTVzHJx.js +1 -0
- package/dist/ui/assets/apache-U0d_L8uA.js +1 -0
- package/dist/ui/assets/apex-CGTLDQj6.js +1 -0
- package/dist/ui/assets/apl-BOpCpqXf.js +1 -0
- package/dist/ui/assets/applescript-CCn79oCD.js +1 -0
- package/dist/ui/assets/ara-4CJ0cIlV.js +1 -0
- package/dist/ui/assets/asciidoc-DE70LPWp.js +1 -0
- package/dist/ui/assets/asm-Cmm7eHzH.js +1 -0
- package/dist/ui/assets/astro-CxPeBwei.js +1 -0
- package/dist/ui/assets/aurora-x-CDeNXAV0.js +1 -0
- package/dist/ui/assets/awk-BWXHIvNe.js +1 -0
- package/dist/ui/assets/ayu-dark-DluEY0Gj.js +1 -0
- package/dist/ui/assets/ayu-light-C3h-C4tm.js +1 -0
- package/dist/ui/assets/ayu-mirage-Bqwy1Gya.js +1 -0
- package/dist/ui/assets/ballerina-B7ZEbQpA.js +1 -0
- package/dist/ui/assets/bat-Bo4NYOV-.js +1 -0
- package/dist/ui/assets/beancount-D-usSTwE.js +1 -0
- package/dist/ui/assets/berry-DKpUyyne.js +1 -0
- package/dist/ui/assets/bibtex-Ci_nEsc7.js +1 -0
- package/dist/ui/assets/bicep-CUHmPFLl.js +1 -0
- package/dist/ui/assets/bird2-C2hNVINV.js +1 -0
- package/dist/ui/assets/blade-DtsAAG4P.js +1 -0
- package/dist/ui/assets/bsl-BkkzgIyY.js +1 -0
- package/dist/ui/assets/c-D9hLjNUM.js +1 -0
- package/dist/ui/assets/c3-CnJL0r0V.js +1 -0
- package/dist/ui/assets/cadence-CQ2zXKGN.js +1 -0
- package/dist/ui/assets/cairo-DLTphjLi.js +1 -0
- package/dist/ui/assets/catppuccin-frappe-3VR1Za6u.js +1 -0
- package/dist/ui/assets/catppuccin-latte-DwIHMF0Q.js +1 -0
- package/dist/ui/assets/catppuccin-macchiato-DYnBP6_5.js +1 -0
- package/dist/ui/assets/catppuccin-mocha-DYhrFGRu.js +1 -0
- package/dist/ui/assets/clarity-SemFz856.js +1 -0
- package/dist/ui/assets/clojure-DqKBuwfJ.js +1 -0
- package/dist/ui/assets/cmake-Bj61d0ZC.js +1 -0
- package/dist/ui/assets/cobol-C1SWlvZm.js +1 -0
- package/dist/ui/assets/codeowners-C8r90Shi.js +1 -0
- package/dist/ui/assets/codeql-oeQT6MSM.js +1 -0
- package/dist/ui/assets/coffee-B71R3v2U.js +1 -0
- package/dist/ui/assets/common-lisp-Cv5bFMCO.js +1 -0
- package/dist/ui/assets/coq-BrsZFFmf.js +1 -0
- package/dist/ui/assets/cpp--5a4c3v4.js +1 -0
- package/dist/ui/assets/crystal-AtqWYtE0.js +1 -0
- package/dist/ui/assets/csharp-Ct8U2NOr.js +1 -0
- package/dist/ui/assets/css-CbqKSHI-.js +1 -0
- package/dist/ui/assets/csv-Dx-8-gkx.js +1 -0
- package/dist/ui/assets/cue-CE9AQfxI.js +1 -0
- package/dist/ui/assets/cypher-ClKdZ_lG.js +1 -0
- package/dist/ui/assets/d-qD-0Kul2.js +1 -0
- package/dist/ui/assets/dark-plus-Cs2F2srj.js +1 -0
- package/dist/ui/assets/dart-DkHntEIa.js +1 -0
- package/dist/ui/assets/dax-BkyTk9wS.js +1 -0
- package/dist/ui/assets/desktop-Dlh5hvp9.js +1 -0
- package/dist/ui/assets/diff-woXpYk--.js +1 -0
- package/dist/ui/assets/docker-IyjqRm3v.js +1 -0
- package/dist/ui/assets/dotenv-_5a1GRtc.js +1 -0
- package/dist/ui/assets/dracula-BHWKrbxM.js +1 -0
- package/dist/ui/assets/dracula-soft-5eyTD99u.js +1 -0
- package/dist/ui/assets/dream-maker-DW3nJb8Q.js +1 -0
- package/dist/ui/assets/edge-BPwY_RrJ.js +1 -0
- package/dist/ui/assets/elixir-DVH2yLJf.js +1 -0
- package/dist/ui/assets/elm-BrleA6gS.js +1 -0
- package/dist/ui/assets/emacs-lisp-C9PiwqqW.js +1 -0
- package/dist/ui/assets/erb-2SHiYe30.js +1 -0
- package/dist/ui/assets/erlang-Cphh6RMH.js +1 -0
- package/dist/ui/assets/everforest-dark-sB-x3p7T.js +1 -0
- package/dist/ui/assets/everforest-light-Df2xbC6M.js +1 -0
- package/dist/ui/assets/fennel-DQxkIbk2.js +1 -0
- package/dist/ui/assets/fish-BJitypiv.js +1 -0
- package/dist/ui/assets/fluent-C03EYrpw.js +1 -0
- package/dist/ui/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
- package/dist/ui/assets/fortran-free-form-CYNrtFtB.js +1 -0
- package/dist/ui/assets/fsharp-D13ZGOAj.js +1 -0
- package/dist/ui/assets/gdresource-C0sCabJj.js +1 -0
- package/dist/ui/assets/gdscript-Cp2uCuqX.js +1 -0
- package/dist/ui/assets/gdshader-CBce3t8t.js +1 -0
- package/dist/ui/assets/genie-CV2tkWYe.js +1 -0
- package/dist/ui/assets/gherkin-DExj1W_8.js +1 -0
- package/dist/ui/assets/git-commit-BSykSTBG.js +1 -0
- package/dist/ui/assets/git-rebase-Bc7atMaV.js +1 -0
- package/dist/ui/assets/github-dark-C-LZuMrd.js +1 -0
- package/dist/ui/assets/github-dark-default-DXG-b-1a.js +1 -0
- package/dist/ui/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
- package/dist/ui/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
- package/dist/ui/assets/github-light-EUqPIrTm.js +1 -0
- package/dist/ui/assets/github-light-default-BXViO-2h.js +1 -0
- package/dist/ui/assets/github-light-high-contrast-B68TUdTA.js +1 -0
- package/dist/ui/assets/gleam-CSRkHgEL.js +1 -0
- package/dist/ui/assets/glimmer-js-DXeTDPtW.js +1 -0
- package/dist/ui/assets/glimmer-ts-CEOoXHU4.js +1 -0
- package/dist/ui/assets/glsl-5-43-Gsg.js +1 -0
- package/dist/ui/assets/gn-ilITqXS6.js +1 -0
- package/dist/ui/assets/gnuplot-7GGW24-e.js +1 -0
- package/dist/ui/assets/go-BJwz_mda.js +1 -0
- package/dist/ui/assets/graphql-Bk7Ah1KA.js +1 -0
- package/dist/ui/assets/groovy-CacY0gHj.js +1 -0
- package/dist/ui/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
- package/dist/ui/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
- package/dist/ui/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
- package/dist/ui/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
- package/dist/ui/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
- package/dist/ui/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
- package/dist/ui/assets/hack-DUHz4rCJ.js +1 -0
- package/dist/ui/assets/haml-BPCuuTPR.js +1 -0
- package/dist/ui/assets/handlebars-CHxmUsnU.js +1 -0
- package/dist/ui/assets/haskell-D8IpX4py.js +1 -0
- package/dist/ui/assets/haxe-OTjmBuCE.js +1 -0
- package/dist/ui/assets/hcl-Dh228itO.js +1 -0
- package/dist/ui/assets/hjson-CxZEssPk.js +1 -0
- package/dist/ui/assets/hlsl-Cvrh5tZx.js +1 -0
- package/dist/ui/assets/horizon-CE9ld1lL.js +1 -0
- package/dist/ui/assets/horizon-bright-Br1oVSNq.js +1 -0
- package/dist/ui/assets/houston-CsvMBhTu.js +1 -0
- package/dist/ui/assets/html-BBJqizz0.js +1 -0
- package/dist/ui/assets/html-derivative-ShTPCcKN.js +1 -0
- package/dist/ui/assets/http-VFTyziwA.js +1 -0
- package/dist/ui/assets/hurl-B8yxTa4r.js +1 -0
- package/dist/ui/assets/hxml-B0Qn7Nwc.js +1 -0
- package/dist/ui/assets/hy-CZbG8q4J.js +1 -0
- package/dist/ui/assets/imba-DsUTQ-LC.js +1 -0
- package/dist/ui/assets/ini-B5eOa1yu.js +1 -0
- package/dist/ui/assets/java-BZ5DAgJZ.js +1 -0
- package/dist/ui/assets/javascript-C_zuIEaC.js +1 -0
- package/dist/ui/assets/jinja-DWd6xfNr.js +1 -0
- package/dist/ui/assets/jison-BbY63d1V.js +1 -0
- package/dist/ui/assets/json-C4DnajZs.js +1 -0
- package/dist/ui/assets/json5-BR5RXkoi.js +1 -0
- package/dist/ui/assets/jsonc-CYpm1nAK.js +1 -0
- package/dist/ui/assets/jsonl-CmCQp5Yx.js +1 -0
- package/dist/ui/assets/jsonnet-CJTPZ8u_.js +1 -0
- package/dist/ui/assets/jssm-DXw9l8Rf.js +1 -0
- package/dist/ui/assets/jsx-C4AACieZ.js +1 -0
- package/dist/ui/assets/julia-sRu7EFMW.js +1 -0
- package/dist/ui/assets/just-DpZ9Sx1v.js +1 -0
- package/dist/ui/assets/kanagawa-dragon-CXtmUGW6.js +1 -0
- package/dist/ui/assets/kanagawa-lotus-BN08jTvb.js +1 -0
- package/dist/ui/assets/kanagawa-wave-CTweb8Dz.js +1 -0
- package/dist/ui/assets/kdl-CsD5j6eV.js +1 -0
- package/dist/ui/assets/kotlin-DhhofPvG.js +1 -0
- package/dist/ui/assets/kusto-BUv0MjJC.js +1 -0
- package/dist/ui/assets/laserwave-C_8bwKvT.js +1 -0
- package/dist/ui/assets/latex-B6a_uum7.js +1 -0
- package/dist/ui/assets/lean-CewbzKMR.js +1 -0
- package/dist/ui/assets/less-DVTAwKKz.js +1 -0
- package/dist/ui/assets/light-plus-DVQuIRkW.js +1 -0
- package/dist/ui/assets/liquid-B2sVpjjr.js +1 -0
- package/dist/ui/assets/llvm-Cm23YOpf.js +1 -0
- package/dist/ui/assets/log-BNLmms1o.js +1 -0
- package/dist/ui/assets/logo-Cluzi2Zq.js +1 -0
- package/dist/ui/assets/lua-DxJJll61.js +1 -0
- package/dist/ui/assets/luau-CNKltnaQ.js +1 -0
- package/dist/ui/assets/make-Dixweg8N.js +1 -0
- package/dist/ui/assets/markdown-BYOwaDjH.js +1 -0
- package/dist/ui/assets/marko-Dx8mw-Wx.js +1 -0
- package/dist/ui/assets/material-theme-Bm3Qr25_.js +1 -0
- package/dist/ui/assets/material-theme-darker-2IIEA8gg.js +1 -0
- package/dist/ui/assets/material-theme-lighter-uhdI0v04.js +1 -0
- package/dist/ui/assets/material-theme-ocean-CHQ94UKr.js +1 -0
- package/dist/ui/assets/material-theme-palenight-B5W6OYN7.js +1 -0
- package/dist/ui/assets/matlab-D7qyCx1q.js +1 -0
- package/dist/ui/assets/mdc-vNKeXEwR.js +1 -0
- package/dist/ui/assets/mdx-DQZ5AkYe.js +1 -0
- package/dist/ui/assets/mermaid-Bk4SNUv9.js +1 -0
- package/dist/ui/assets/min-dark-BSWPekZh.js +1 -0
- package/dist/ui/assets/min-light-DDpmG2fV.js +1 -0
- package/dist/ui/assets/mipsasm-BMqwQI7S.js +1 -0
- package/dist/ui/assets/mojo-BgCJLMeH.js +1 -0
- package/dist/ui/assets/monokai-CdkpiU2Y.js +1 -0
- package/dist/ui/assets/moonbit-CaWjb8XO.js +1 -0
- package/dist/ui/assets/move-B1IS1UjX.js +1 -0
- package/dist/ui/assets/narrat-_X_XdTYD.js +1 -0
- package/dist/ui/assets/nextflow-Bbiyy34d.js +1 -0
- package/dist/ui/assets/nextflow-groovy-Dc_ddanL.js +1 -0
- package/dist/ui/assets/nginx-DScQAGLT.js +1 -0
- package/dist/ui/assets/night-owl-DhmEMT88.js +1 -0
- package/dist/ui/assets/night-owl-light-eJ-hLW7d.js +1 -0
- package/dist/ui/assets/nim-lAJch9uT.js +1 -0
- package/dist/ui/assets/nix-IvuFDN5E.js +1 -0
- package/dist/ui/assets/nord-Cb4Vim4T.js +1 -0
- package/dist/ui/assets/nushell-DcLAeLz5.js +1 -0
- package/dist/ui/assets/objective-c-D1A_Heim.js +1 -0
- package/dist/ui/assets/objective-cpp-BsSzOQcm.js +1 -0
- package/dist/ui/assets/ocaml-O90oeIOV.js +1 -0
- package/dist/ui/assets/odin-B1RWQWA5.js +1 -0
- package/dist/ui/assets/one-dark-pro-CLwyXe_n.js +1 -0
- package/dist/ui/assets/one-light-D7Lr4KcI.js +1 -0
- package/dist/ui/assets/openscad-BUDT5pXO.js +1 -0
- package/dist/ui/assets/pascal-4ZHwLPI5.js +1 -0
- package/dist/ui/assets/perl-C_GkVo_E.js +1 -0
- package/dist/ui/assets/php-DziV3K6J.js +1 -0
- package/dist/ui/assets/pierre-dark-CpLgRqie.js +1 -0
- package/dist/ui/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
- package/dist/ui/assets/pierre-dark-soft-kZQmAZld.js +1 -0
- package/dist/ui/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
- package/dist/ui/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
- package/dist/ui/assets/pierre-light-CoaEpmwp.js +1 -0
- package/dist/ui/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
- package/dist/ui/assets/pierre-light-soft-lWLdNTOI.js +1 -0
- package/dist/ui/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
- package/dist/ui/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
- package/dist/ui/assets/pkl-ot-7Btpt.js +1 -0
- package/dist/ui/assets/plastic-DQwYfKfQ.js +1 -0
- package/dist/ui/assets/plsql-DGHpHOYJ.js +1 -0
- package/dist/ui/assets/po-BiJDBrnU.js +1 -0
- package/dist/ui/assets/poimandres-DRFjx7u4.js +1 -0
- package/dist/ui/assets/polar-C7UOKdEL.js +1 -0
- package/dist/ui/assets/postcss-BXeXVLqQ.js +1 -0
- package/dist/ui/assets/powerquery-DNMTfnFr.js +1 -0
- package/dist/ui/assets/powershell-DshXNtvi.js +1 -0
- package/dist/ui/assets/prisma-BsRQq5mF.js +1 -0
- package/dist/ui/assets/prolog-iXnhIJG7.js +1 -0
- package/dist/ui/assets/proto-DB4EqR-F.js +1 -0
- package/dist/ui/assets/pug-z75UIWVK.js +1 -0
- package/dist/ui/assets/puppet-CDv2pdJW.js +1 -0
- package/dist/ui/assets/purescript-9MfHhQsQ.js +1 -0
- package/dist/ui/assets/python-gzcpVVnB.js +1 -0
- package/dist/ui/assets/qml-Cmm4coz1.js +1 -0
- package/dist/ui/assets/qmldir-DCQb3MpD.js +1 -0
- package/dist/ui/assets/qss-Fe1Jh2GI.js +1 -0
- package/dist/ui/assets/r-Brd0axBE.js +1 -0
- package/dist/ui/assets/racket-DcIDlBhZ.js +1 -0
- package/dist/ui/assets/raku-B3gFvitq.js +1 -0
- package/dist/ui/assets/razor-DSbwmoiu.js +1 -0
- package/dist/ui/assets/red-CJ3rzSJv.js +1 -0
- package/dist/ui/assets/reg-CRGYupPL.js +1 -0
- package/dist/ui/assets/regexp-Bs3Uk-pY.js +1 -0
- package/dist/ui/assets/rel-BtDbiS_P.js +1 -0
- package/dist/ui/assets/review-payload-CbwCBKB1.js +1580 -0
- package/dist/ui/assets/riscv-Ckw8ddFX.js +1 -0
- package/dist/ui/assets/ron-VUp2lXgN.js +1 -0
- package/dist/ui/assets/rose-pine-BthvhNj6.js +1 -0
- package/dist/ui/assets/rose-pine-dawn-Dg85fqjY.js +1 -0
- package/dist/ui/assets/rose-pine-moon-hon4tzzS.js +1 -0
- package/dist/ui/assets/rosmsg-CAekHB0j.js +1 -0
- package/dist/ui/assets/rst-ChIyKpUC.js +1 -0
- package/dist/ui/assets/ruby-BdAmvOMO.js +1 -0
- package/dist/ui/assets/rust-Cfkwpbl8.js +1 -0
- package/dist/ui/assets/sas-DpXn8hc5.js +1 -0
- package/dist/ui/assets/sass-DXrisJhu.js +1 -0
- package/dist/ui/assets/scala-DKOlJaKm.js +1 -0
- package/dist/ui/assets/scheme-DQCgrYNe.js +1 -0
- package/dist/ui/assets/scss-atX1Uuef.js +1 -0
- package/dist/ui/assets/sdbl-bTVj8UrX.js +1 -0
- package/dist/ui/assets/shaderlab-TOUzSsQk.js +1 -0
- package/dist/ui/assets/shellscript-BqgcAeMK.js +1 -0
- package/dist/ui/assets/shellsession-DfQSMRN5.js +1 -0
- package/dist/ui/assets/slack-dark-DnToyrRv.js +1 -0
- package/dist/ui/assets/slack-ochin-B2OO5cIa.js +1 -0
- package/dist/ui/assets/smalltalk-B16xEiuN.js +1 -0
- package/dist/ui/assets/snazzy-light-4G7pJPwS.js +1 -0
- package/dist/ui/assets/solarized-dark-DV17i1UV.js +1 -0
- package/dist/ui/assets/solarized-light-DSh2HLQt.js +1 -0
- package/dist/ui/assets/solidity-CKzVLygQ.js +1 -0
- package/dist/ui/assets/soy-DzP7zZTB.js +1 -0
- package/dist/ui/assets/sparql-D_iOobhT.js +1 -0
- package/dist/ui/assets/splunk-BC2Px7Mm.js +1 -0
- package/dist/ui/assets/sql-gmaLk66z.js +1 -0
- package/dist/ui/assets/ssh-config-BgfXC-Er.js +1 -0
- package/dist/ui/assets/stata-CJ0YTMcV.js +1 -0
- package/dist/ui/assets/stylus-B6D30XZt.js +1 -0
- package/dist/ui/assets/surrealql-LH7FciQz.js +1 -0
- package/dist/ui/assets/svelte-BME2PU6V.js +1 -0
- package/dist/ui/assets/swift-DonLKvLd.js +1 -0
- package/dist/ui/assets/synthwave-84-nFMaYfgc.js +1 -0
- package/dist/ui/assets/system-verilog-DJ5XKQeo.js +1 -0
- package/dist/ui/assets/systemd-BxMlprV5.js +1 -0
- package/dist/ui/assets/talonscript-CohzipZa.js +1 -0
- package/dist/ui/assets/tasl-DMoTqEGO.js +1 -0
- package/dist/ui/assets/tcl-CZd0xW_V.js +1 -0
- package/dist/ui/assets/templ-DHBNIfYW.js +1 -0
- package/dist/ui/assets/terraform-DswuEJGm.js +1 -0
- package/dist/ui/assets/tex-C8-kPEzO.js +1 -0
- package/dist/ui/assets/tokyo-night-oM2G3aXe.js +1 -0
- package/dist/ui/assets/toml-CcmNWLt0.js +1 -0
- package/dist/ui/assets/ts-tags-CiewV0vR.js +1 -0
- package/dist/ui/assets/tsv-sltzmVWM.js +1 -0
- package/dist/ui/assets/tsx-CUYPqmnq.js +1 -0
- package/dist/ui/assets/turtle-ByJddavk.js +1 -0
- package/dist/ui/assets/twig-BTkvsl0b.js +1 -0
- package/dist/ui/assets/typescript-DDQMaPwj.js +1 -0
- package/dist/ui/assets/typespec-B88KGewJ.js +1 -0
- package/dist/ui/assets/typst-DI99ib-x.js +1 -0
- package/dist/ui/assets/v-DETTlOr0.js +1 -0
- package/dist/ui/assets/vala-zf12oZj6.js +1 -0
- package/dist/ui/assets/vb-Djn5o6TS.js +1 -0
- package/dist/ui/assets/verilog-CiiDBU1e.js +1 -0
- package/dist/ui/assets/vesper-D5bVUKB1.js +1 -0
- package/dist/ui/assets/vhdl-BroJfC0k.js +1 -0
- package/dist/ui/assets/viml-DvXPmvsu.js +1 -0
- package/dist/ui/assets/vitesse-black-fwtXNY1n.js +1 -0
- package/dist/ui/assets/vitesse-dark-BZCL-v6S.js +1 -0
- package/dist/ui/assets/vitesse-light-VbXTXTou.js +1 -0
- package/dist/ui/assets/vue-BH5SEWRH.js +1 -0
- package/dist/ui/assets/vue-html-BT7yeYez.js +1 -0
- package/dist/ui/assets/vue-vine-Cs5IN2rs.js +1 -0
- package/dist/ui/assets/vyper-CgoNMtux.js +1 -0
- package/dist/ui/assets/wasm-BnjxR4X6.js +1 -0
- package/dist/ui/assets/wasm-ByWQv1Qj.js +1 -0
- package/dist/ui/assets/wenyan-C8pVoKbM.js +1 -0
- package/dist/ui/assets/wgsl-BsKzXJz4.js +1 -0
- package/dist/ui/assets/wikitext-ClFFjSW2.js +1 -0
- package/dist/ui/assets/wit-DdvCle-K.js +1 -0
- package/dist/ui/assets/wolfram-DLL8P-h_.js +1 -0
- package/dist/ui/assets/workspace-app-B_BnSEHO.css +1 -0
- package/dist/ui/assets/workspace-app-DSFpnrIC.js +115 -0
- package/dist/ui/assets/xml-D3_1BEcO.js +1 -0
- package/dist/ui/assets/xsl-BBOCDn4Y.js +1 -0
- package/dist/ui/assets/yaml-lThBDT45.js +1 -0
- package/dist/ui/assets/zenscript-BnlCZFoB.js +1 -0
- package/dist/ui/assets/zig-CMLA9XwU.js +1 -0
- package/dist/ui/workspace-app.html +15 -0
- package/dist/user-config.js +228 -0
- package/dist/verification.js +74 -0
- package/dist/workspace-store.js +133 -0
- package/dist/workspaces.js +433 -0
- package/docs/adr/devspace-x-implementation-adrs.md +159 -0
- package/docs/agent-profile-schema.md +203 -0
- package/docs/artifact-exchange.md +44 -0
- package/docs/assets/devspace-logo-light.png +0 -0
- package/docs/assets/devspace-screenshot.png +0 -0
- package/docs/assets/v11-review-ui-after.png +0 -0
- package/docs/assets/v11-review-ui-before.png +0 -0
- package/docs/chatgpt-coding-workflow.md +215 -0
- package/docs/configuration.md +217 -0
- package/docs/gotchas.md +294 -0
- package/docs/local-agent-daemon.md +101 -0
- package/docs/security.md +197 -0
- package/docs/setup.md +174 -0
- package/examples/agents/claude-implementer.md +30 -0
- package/examples/agents/codex-explorer.md +27 -0
- package/examples/agents/codex-qa-tester.md +29 -0
- package/examples/agents/codex-worker.md +25 -0
- package/examples/agents/copilot-reviewer.md +25 -0
- package/examples/agents/cursor-agent-worker.md +26 -0
- package/examples/agents/grok-builder.md +10 -0
- package/examples/agents/opencode-explorer.md +27 -0
- package/examples/agents/pi-reviewer.md +27 -0
- package/package.json +102 -0
- package/schema/v1/hearth.schema.json +529 -0
- package/scripts/copy-dashboard.mjs +9 -0
- package/scripts/fix-node-pty-permissions.mjs +22 -0
- package/scripts/generate-config-schema.ts +9 -0
- package/skills/subagents/SKILL.md +57 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { filterChildEnvironment } from "./policy/env-allowlist.js";
|
|
3
|
+
import { resolveShellCommand, terminateProcessTree } from "./process-platform.js";
|
|
4
|
+
const DEFAULT_EXEC_YIELD_MS = 10_000;
|
|
5
|
+
const DEFAULT_INTERACTIVE_YIELD_MS = 250;
|
|
6
|
+
const DEFAULT_POLL_YIELD_MS = 5_000;
|
|
7
|
+
const MAX_COMMAND_YIELD_MS = 30_000;
|
|
8
|
+
const MAX_POLL_YIELD_MS = 110_000;
|
|
9
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 10_000;
|
|
10
|
+
const DEFAULT_BUFFER_CHARACTERS = 1_000_000;
|
|
11
|
+
const COMPLETED_SESSION_TTL_MS = 5 * 60 * 1_000;
|
|
12
|
+
const DEFAULT_COLUMNS = 80;
|
|
13
|
+
const DEFAULT_ROWS = 24;
|
|
14
|
+
function boundedInteger(value, fallback, maximum) {
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return fallback;
|
|
17
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
18
|
+
throw new Error("Duration and output limits must be non-negative.");
|
|
19
|
+
}
|
|
20
|
+
return Math.min(Math.floor(value), maximum);
|
|
21
|
+
}
|
|
22
|
+
function terminalSize(value, fallback) {
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return fallback;
|
|
25
|
+
if (!Number.isInteger(value) || value < 1 || value > 1_000) {
|
|
26
|
+
throw new Error("Terminal dimensions must be integers between 1 and 1000.");
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function processEnvironment(baseEnvironment, input) {
|
|
31
|
+
return {
|
|
32
|
+
...baseEnvironment,
|
|
33
|
+
NO_COLOR: "1",
|
|
34
|
+
TERM: "dumb",
|
|
35
|
+
PAGER: "cat",
|
|
36
|
+
GIT_PAGER: "cat",
|
|
37
|
+
GH_PAGER: "cat",
|
|
38
|
+
CODEX_CI: "1",
|
|
39
|
+
LANG: process.env.LANG ?? "C.UTF-8",
|
|
40
|
+
LC_ALL: process.env.LC_ALL ?? "C.UTF-8",
|
|
41
|
+
// Marks shells spawned by Hearth tools so CLI helpers invoked from a
|
|
42
|
+
// model-run command cannot bypass workspace scoping.
|
|
43
|
+
HEARTH_ORIGIN: "hearth-shell",
|
|
44
|
+
...(input?.workspaceId ? { HEARTH_WORKSPACE_ID: input.workspaceId } : {}),
|
|
45
|
+
...(input?.workspaceRoot ? { HEARTH_WORKSPACE_ROOT: input.workspaceRoot } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function codePointLength(value) {
|
|
49
|
+
return Array.from(value).length;
|
|
50
|
+
}
|
|
51
|
+
function sliceCodePoints(value, start, end) {
|
|
52
|
+
return Array.from(value).slice(start, end).join("");
|
|
53
|
+
}
|
|
54
|
+
function takeHead(value, count) {
|
|
55
|
+
if (count <= 0)
|
|
56
|
+
return "";
|
|
57
|
+
return sliceCodePoints(value, 0, count);
|
|
58
|
+
}
|
|
59
|
+
function takeTail(value, count) {
|
|
60
|
+
if (count <= 0)
|
|
61
|
+
return "";
|
|
62
|
+
const characters = Array.from(value);
|
|
63
|
+
return characters.slice(Math.max(0, characters.length - count)).join("");
|
|
64
|
+
}
|
|
65
|
+
function splitBudget(maxCharacters) {
|
|
66
|
+
return {
|
|
67
|
+
head: Math.ceil(maxCharacters / 2),
|
|
68
|
+
tail: Math.floor(maxCharacters / 2),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function formatHeadTail(head, tail, omittedCharacters) {
|
|
72
|
+
if (omittedCharacters <= 0)
|
|
73
|
+
return head + tail;
|
|
74
|
+
return `${head}\n... output truncated (${omittedCharacters} characters omitted) ...\n${tail}`;
|
|
75
|
+
}
|
|
76
|
+
export class HeadTailBuffer {
|
|
77
|
+
maxCharacters;
|
|
78
|
+
head = "";
|
|
79
|
+
tail = "";
|
|
80
|
+
totalCharacters = 0;
|
|
81
|
+
constructor(maxCharacters) {
|
|
82
|
+
this.maxCharacters = maxCharacters;
|
|
83
|
+
if (!Number.isInteger(maxCharacters) || maxCharacters < 1) {
|
|
84
|
+
throw new Error("Head/tail buffer limit must be a positive integer.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
append(output) {
|
|
88
|
+
if (!output)
|
|
89
|
+
return;
|
|
90
|
+
const previousTotal = this.totalCharacters;
|
|
91
|
+
this.totalCharacters += codePointLength(output);
|
|
92
|
+
if (this.totalCharacters <= this.maxCharacters) {
|
|
93
|
+
this.head += output;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const budget = splitBudget(this.maxCharacters);
|
|
97
|
+
if (previousTotal <= this.maxCharacters) {
|
|
98
|
+
const fullOutput = this.head + output;
|
|
99
|
+
this.head = takeHead(fullOutput, budget.head);
|
|
100
|
+
this.tail = takeTail(fullOutput, budget.tail);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.tail = takeTail(this.tail + output, budget.tail);
|
|
104
|
+
}
|
|
105
|
+
hasOutput() {
|
|
106
|
+
return this.totalCharacters > 0;
|
|
107
|
+
}
|
|
108
|
+
drain(maxCharacters) {
|
|
109
|
+
if (!Number.isInteger(maxCharacters) || maxCharacters < 1) {
|
|
110
|
+
throw new Error("Output limit must be a positive integer.");
|
|
111
|
+
}
|
|
112
|
+
const omittedByBuffer = Math.max(0, this.totalCharacters - codePointLength(this.head) - codePointLength(this.tail));
|
|
113
|
+
const retained = formatHeadTail(this.head, this.tail, omittedByBuffer);
|
|
114
|
+
const output = truncateOutput(retained, maxCharacters);
|
|
115
|
+
const truncated = omittedByBuffer > 0 || output.truncated;
|
|
116
|
+
this.head = "";
|
|
117
|
+
this.tail = "";
|
|
118
|
+
this.totalCharacters = 0;
|
|
119
|
+
return { output: output.output, truncated };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function truncateOutput(output, maxCharacters) {
|
|
123
|
+
const outputCharacters = codePointLength(output);
|
|
124
|
+
if (outputCharacters <= maxCharacters)
|
|
125
|
+
return { output, truncated: false };
|
|
126
|
+
const marker = "\n... output truncated ...\n";
|
|
127
|
+
const markerCharacters = codePointLength(marker);
|
|
128
|
+
const available = Math.max(0, maxCharacters - markerCharacters);
|
|
129
|
+
const budget = splitBudget(available);
|
|
130
|
+
return {
|
|
131
|
+
output: takeHead(output, budget.head) + marker + takeTail(output, budget.tail),
|
|
132
|
+
truncated: true,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export class ProcessSessionManager {
|
|
136
|
+
sessions = new Map();
|
|
137
|
+
maxBufferCharacters;
|
|
138
|
+
completedSessionTtlMs;
|
|
139
|
+
environment;
|
|
140
|
+
commandWrapper;
|
|
141
|
+
journalDir;
|
|
142
|
+
nextSessionId = 1;
|
|
143
|
+
constructor(options = {}) {
|
|
144
|
+
this.maxBufferCharacters = options.maxBufferCharacters ?? DEFAULT_BUFFER_CHARACTERS;
|
|
145
|
+
this.completedSessionTtlMs = options.completedSessionTtlMs ?? COMPLETED_SESSION_TTL_MS;
|
|
146
|
+
this.environment = options.environment ?? { allowAll: true };
|
|
147
|
+
this.commandWrapper = options.commandWrapper;
|
|
148
|
+
this.journalDir = options.journalDir;
|
|
149
|
+
}
|
|
150
|
+
async start(input) {
|
|
151
|
+
const session = this.createSession(input);
|
|
152
|
+
this.sessions.set(session.id, session);
|
|
153
|
+
try {
|
|
154
|
+
if (input.tty && process.platform !== "win32")
|
|
155
|
+
await this.startPty(session, input);
|
|
156
|
+
else
|
|
157
|
+
this.startPipe(session, input);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
this.sessions.delete(session.id);
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
const yieldTimeMs = boundedInteger(input.yieldTimeMs, DEFAULT_EXEC_YIELD_MS, MAX_COMMAND_YIELD_MS);
|
|
164
|
+
await this.waitForExit(session, yieldTimeMs);
|
|
165
|
+
const snapshot = this.consume(session, input.maxOutputTokens);
|
|
166
|
+
if (!session.running)
|
|
167
|
+
this.removeSession(session.id);
|
|
168
|
+
return snapshot;
|
|
169
|
+
}
|
|
170
|
+
async write(input) {
|
|
171
|
+
const session = this.getOwnedSession(input.workspaceId, input.sessionId);
|
|
172
|
+
const chars = input.chars ?? "";
|
|
173
|
+
const interactionRequested = chars.length > 0 || input.columns !== undefined || input.rows !== undefined;
|
|
174
|
+
if (input.columns !== undefined || input.rows !== undefined) {
|
|
175
|
+
session.columns = terminalSize(input.columns, session.columns);
|
|
176
|
+
session.rows = terminalSize(input.rows, session.rows);
|
|
177
|
+
if (!session.process?.resize) {
|
|
178
|
+
throw new Error(`Process session ${session.id} is not a PTY and cannot be resized.`);
|
|
179
|
+
}
|
|
180
|
+
session.process.resize(session.columns, session.rows);
|
|
181
|
+
}
|
|
182
|
+
const interruptRequested = chars.includes("\u0003") && session.running;
|
|
183
|
+
if (interruptRequested) {
|
|
184
|
+
session.process?.kill("SIGINT");
|
|
185
|
+
}
|
|
186
|
+
const writableChars = chars.replaceAll("\u0003", "");
|
|
187
|
+
if (writableChars && session.running)
|
|
188
|
+
session.process?.write(writableChars);
|
|
189
|
+
if ((interactionRequested || !session.buffer.hasOutput()) && session.running) {
|
|
190
|
+
const fallback = interactionRequested ? DEFAULT_INTERACTIVE_YIELD_MS : DEFAULT_POLL_YIELD_MS;
|
|
191
|
+
const maximum = interactionRequested ? MAX_COMMAND_YIELD_MS : MAX_POLL_YIELD_MS;
|
|
192
|
+
const yieldTimeMs = boundedInteger(input.yieldTimeMs, fallback, maximum);
|
|
193
|
+
await this.waitForExit(session, yieldTimeMs);
|
|
194
|
+
}
|
|
195
|
+
const snapshot = this.consume(session, input.maxOutputTokens);
|
|
196
|
+
if (!session.running)
|
|
197
|
+
this.removeSession(session.id);
|
|
198
|
+
return snapshot;
|
|
199
|
+
}
|
|
200
|
+
terminate(workspaceId, sessionId) {
|
|
201
|
+
const session = this.getOwnedSession(workspaceId, sessionId);
|
|
202
|
+
if (session.running)
|
|
203
|
+
session.process?.kill("SIGTERM");
|
|
204
|
+
}
|
|
205
|
+
shutdown() {
|
|
206
|
+
for (const session of this.sessions.values()) {
|
|
207
|
+
if (session.cleanupTimer)
|
|
208
|
+
clearTimeout(session.cleanupTimer);
|
|
209
|
+
if (session.running)
|
|
210
|
+
session.process?.kill("SIGTERM");
|
|
211
|
+
}
|
|
212
|
+
this.sessions.clear();
|
|
213
|
+
}
|
|
214
|
+
async waitForExit(session, yieldTimeMs) {
|
|
215
|
+
let timer;
|
|
216
|
+
try {
|
|
217
|
+
await Promise.race([
|
|
218
|
+
session.exitPromise,
|
|
219
|
+
new Promise((resolve) => {
|
|
220
|
+
timer = setTimeout(resolve, yieldTimeMs);
|
|
221
|
+
}),
|
|
222
|
+
]);
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
if (timer)
|
|
226
|
+
clearTimeout(timer);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
resolveShell(input) {
|
|
230
|
+
const shell = resolveShellCommand(input.command);
|
|
231
|
+
if (input.sandbox && this.commandWrapper && input.workspaceRoot) {
|
|
232
|
+
try {
|
|
233
|
+
return this.commandWrapper(shell, { workspaceRoot: input.workspaceRoot });
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
// Sandbox failures fall back to the unwrapped command; the wrapper
|
|
237
|
+
// logs why (best-effort hardening, never a silent behavior change).
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return shell;
|
|
241
|
+
}
|
|
242
|
+
createSession(input) {
|
|
243
|
+
let resolveExit = () => undefined;
|
|
244
|
+
const exitPromise = new Promise((resolve) => {
|
|
245
|
+
resolveExit = resolve;
|
|
246
|
+
});
|
|
247
|
+
return {
|
|
248
|
+
id: this.nextSessionId++,
|
|
249
|
+
workspaceId: input.workspaceId,
|
|
250
|
+
startedAt: Date.now(),
|
|
251
|
+
columns: terminalSize(input.columns, DEFAULT_COLUMNS),
|
|
252
|
+
rows: terminalSize(input.rows, DEFAULT_ROWS),
|
|
253
|
+
buffer: new HeadTailBuffer(this.maxBufferCharacters),
|
|
254
|
+
running: true,
|
|
255
|
+
exitPromise,
|
|
256
|
+
resolveExit,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
startPipe(session, input) {
|
|
260
|
+
const shell = this.resolveShell(input);
|
|
261
|
+
const detached = process.platform !== "win32";
|
|
262
|
+
// Spawn the resolved (possibly sandbox-wrapped) shell directly. Node's
|
|
263
|
+
// `shell:` spawn option would append `-c <command>` to whatever executable
|
|
264
|
+
// it is given, which breaks wrappers like `bwrap` ("Unknown option -c").
|
|
265
|
+
// resolveShellCommand already embeds the command in shell.args.
|
|
266
|
+
const child = spawn(shell.executable, shell.args, {
|
|
267
|
+
cwd: input.cwd,
|
|
268
|
+
env: processEnvironment(filterChildEnvironment(process.env, this.environment, { workspaceId: input.workspaceId }), {
|
|
269
|
+
workspaceId: input.workspaceId,
|
|
270
|
+
workspaceRoot: input.workspaceRoot,
|
|
271
|
+
}),
|
|
272
|
+
stdio: "pipe",
|
|
273
|
+
windowsHide: true,
|
|
274
|
+
detached,
|
|
275
|
+
});
|
|
276
|
+
session.process = {
|
|
277
|
+
write: (data) => child.stdin.write(data),
|
|
278
|
+
kill: (signal = "SIGTERM") => terminateProcessTree(child, signal, detached),
|
|
279
|
+
resize: input.tty ? () => undefined : undefined,
|
|
280
|
+
};
|
|
281
|
+
child.stdout.on("data", (data) => this.append(session, data.toString("utf8")));
|
|
282
|
+
child.stderr.on("data", (data) => this.append(session, data.toString("utf8")));
|
|
283
|
+
child.on("error", (error) => this.append(session, `${error.message}\n`));
|
|
284
|
+
child.on("close", (code, signal) => this.finish(session, code ?? undefined, signal ?? undefined));
|
|
285
|
+
this.journal(session, input, child.pid);
|
|
286
|
+
}
|
|
287
|
+
async startPty(session, input) {
|
|
288
|
+
let nodePty;
|
|
289
|
+
try {
|
|
290
|
+
nodePty = await import("node-pty");
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
throw new Error("PTY support requires the optional node-pty dependency.");
|
|
294
|
+
}
|
|
295
|
+
const shell = this.resolveShell(input);
|
|
296
|
+
let pty;
|
|
297
|
+
try {
|
|
298
|
+
pty = nodePty.spawn(shell.executable, shell.args, {
|
|
299
|
+
cwd: input.cwd,
|
|
300
|
+
env: processEnvironment(filterChildEnvironment(process.env, this.environment, { workspaceId: input.workspaceId }), {
|
|
301
|
+
workspaceId: input.workspaceId,
|
|
302
|
+
workspaceRoot: input.workspaceRoot,
|
|
303
|
+
}),
|
|
304
|
+
name: "xterm-256color",
|
|
305
|
+
cols: session.columns,
|
|
306
|
+
rows: session.rows,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
throw error;
|
|
311
|
+
}
|
|
312
|
+
session.process = {
|
|
313
|
+
write: (data) => pty.write(data),
|
|
314
|
+
kill: (signal) => pty.kill(signal),
|
|
315
|
+
resize: (columns, rows) => pty.resize(columns, rows),
|
|
316
|
+
};
|
|
317
|
+
pty.onData((data) => this.append(session, data));
|
|
318
|
+
pty.onExit(({ exitCode, signal }) => {
|
|
319
|
+
this.finish(session, exitCode, signal === 0 ? undefined : String(signal));
|
|
320
|
+
});
|
|
321
|
+
this.journal(session, input, pty.pid);
|
|
322
|
+
}
|
|
323
|
+
finish(session, exitCode, signal) {
|
|
324
|
+
if (!session.running)
|
|
325
|
+
return;
|
|
326
|
+
session.running = false;
|
|
327
|
+
session.exitCode = exitCode;
|
|
328
|
+
session.signal = signal;
|
|
329
|
+
session.resolveExit();
|
|
330
|
+
this.unjournal(session);
|
|
331
|
+
session.cleanupTimer = setTimeout(() => this.sessions.delete(session.id), this.completedSessionTtlMs);
|
|
332
|
+
session.cleanupTimer.unref();
|
|
333
|
+
}
|
|
334
|
+
append(session, output) {
|
|
335
|
+
session.buffer.append(output);
|
|
336
|
+
}
|
|
337
|
+
consume(session, maxOutputTokens) {
|
|
338
|
+
const limit = boundedInteger(maxOutputTokens, DEFAULT_MAX_OUTPUT_TOKENS, 100_000);
|
|
339
|
+
const maxCharacters = Math.max(256, limit * 4);
|
|
340
|
+
const buffered = session.buffer.drain(maxCharacters);
|
|
341
|
+
return {
|
|
342
|
+
sessionId: session.running ? session.id : undefined,
|
|
343
|
+
output: buffered.output,
|
|
344
|
+
outputTruncated: buffered.truncated,
|
|
345
|
+
running: session.running,
|
|
346
|
+
exitCode: session.exitCode,
|
|
347
|
+
signal: session.signal,
|
|
348
|
+
wallTimeMs: Date.now() - session.startedAt,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
getOwnedSession(workspaceId, sessionId) {
|
|
352
|
+
const session = this.sessions.get(sessionId);
|
|
353
|
+
if (!session)
|
|
354
|
+
throw new Error(`Unknown process session: ${sessionId}`);
|
|
355
|
+
if (session.workspaceId !== workspaceId) {
|
|
356
|
+
throw new Error(`Process session ${sessionId} does not belong to workspace ${workspaceId}.`);
|
|
357
|
+
}
|
|
358
|
+
return session;
|
|
359
|
+
}
|
|
360
|
+
removeSession(sessionId) {
|
|
361
|
+
const session = this.sessions.get(sessionId);
|
|
362
|
+
this.unjournal(session);
|
|
363
|
+
if (session?.cleanupTimer)
|
|
364
|
+
clearTimeout(session.cleanupTimer);
|
|
365
|
+
this.sessions.delete(sessionId);
|
|
366
|
+
}
|
|
367
|
+
/** Best-effort journal write; never blocks or throws into the spawn path. */
|
|
368
|
+
journal(session, input, pid) {
|
|
369
|
+
if (!this.journalDir || !pid || pid <= 1)
|
|
370
|
+
return;
|
|
371
|
+
session.journalPid = pid;
|
|
372
|
+
void import("./process-journal.js").then(({ recordProcessJournal }) => recordProcessJournal(this.journalDir, {
|
|
373
|
+
pid,
|
|
374
|
+
pgid: process.platform === "win32" ? undefined : pid,
|
|
375
|
+
workspaceId: input.workspaceId,
|
|
376
|
+
workspaceRoot: input.workspaceRoot ?? input.cwd,
|
|
377
|
+
commandPreview: input.command.slice(0, 120),
|
|
378
|
+
startedAt: new Date().toISOString(),
|
|
379
|
+
}).catch(() => undefined)).catch(() => undefined);
|
|
380
|
+
}
|
|
381
|
+
unjournal(session) {
|
|
382
|
+
if (!session || !this.journalDir || !session.journalPid)
|
|
383
|
+
return;
|
|
384
|
+
const pid = session.journalPid;
|
|
385
|
+
session.journalPid = undefined;
|
|
386
|
+
void import("./process-journal.js").then(({ removeProcessJournal }) => removeProcessJournal(this.journalDir, pid).catch(() => undefined)).catch(() => undefined);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { requestIp } from "./logger.js";
|
|
2
|
+
/**
|
|
3
|
+
* Small in-memory sliding-window limiter. State is per-process by design:
|
|
4
|
+
* Hearth runs as a single local server process, so this needs no shared
|
|
5
|
+
* store. Keys that go idle are evicted lazily to keep the map bounded.
|
|
6
|
+
*/
|
|
7
|
+
export class RateLimiter {
|
|
8
|
+
options;
|
|
9
|
+
buckets = new Map();
|
|
10
|
+
lastSweep = 0;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
take(key, now = Date.now()) {
|
|
15
|
+
this.sweep(now);
|
|
16
|
+
const bucketKey = `${this.options.keyPrefix}:${key}`;
|
|
17
|
+
const bucket = this.buckets.get(bucketKey) ?? { hits: [] };
|
|
18
|
+
const cutoff = now - this.options.rule.windowMs;
|
|
19
|
+
bucket.hits = bucket.hits.filter((hit) => hit > cutoff);
|
|
20
|
+
if (bucket.hits.length >= this.options.rule.limit) {
|
|
21
|
+
const oldest = bucket.hits[0];
|
|
22
|
+
const retryAfterSeconds = Math.max(1, Math.ceil((oldest + this.options.rule.windowMs - now) / 1000));
|
|
23
|
+
this.buckets.set(bucketKey, bucket);
|
|
24
|
+
return { allowed: false, retryAfterSeconds };
|
|
25
|
+
}
|
|
26
|
+
bucket.hits.push(now);
|
|
27
|
+
this.buckets.set(bucketKey, bucket);
|
|
28
|
+
return { allowed: true, retryAfterSeconds: 0 };
|
|
29
|
+
}
|
|
30
|
+
/** Successful authorizations reset the failure window for the key. */
|
|
31
|
+
reset(key) {
|
|
32
|
+
this.buckets.delete(`${this.options.keyPrefix}:${key}`);
|
|
33
|
+
}
|
|
34
|
+
sweep(now) {
|
|
35
|
+
if (now - this.lastSweep < 60_000 && this.buckets.size < 10_000)
|
|
36
|
+
return;
|
|
37
|
+
this.lastSweep = now;
|
|
38
|
+
const cutoff = now - this.options.rule.windowMs;
|
|
39
|
+
for (const [key, bucket] of this.buckets) {
|
|
40
|
+
if (!bucket.hits.some((hit) => hit > cutoff))
|
|
41
|
+
this.buckets.delete(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function ipRateLimitMiddleware(limiter, trustProxy) {
|
|
46
|
+
return (req, res, next) => {
|
|
47
|
+
const ip = requestIp(req, trustProxy) ?? "unknown";
|
|
48
|
+
const result = limiter.take(ip);
|
|
49
|
+
if (result.allowed) {
|
|
50
|
+
next();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
res.setHeader("Retry-After", String(result.retryAfterSeconds));
|
|
54
|
+
res.status(429).json({
|
|
55
|
+
error: "rate_limited",
|
|
56
|
+
error_description: "Too many requests. Try again later.",
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export const DEFAULT_AUTH_RATE_LIMITS = {
|
|
61
|
+
authorizeRule: { limit: 20, windowMs: 60 * 60 * 1000 },
|
|
62
|
+
registerRule: { limit: 30, windowMs: 60 * 60 * 1000 },
|
|
63
|
+
tokenRule: { limit: 120, windowMs: 60 * 60 * 1000 },
|
|
64
|
+
};
|
|
65
|
+
export function createAuthRateLimiters(trustProxy, config = DEFAULT_AUTH_RATE_LIMITS) {
|
|
66
|
+
const authorizeLimiter = new RateLimiter({ keyPrefix: "authorize", rule: config.authorizeRule });
|
|
67
|
+
const registerLimiter = new RateLimiter({ keyPrefix: "register", rule: config.registerRule });
|
|
68
|
+
const tokenLimiter = new RateLimiter({ keyPrefix: "token", rule: config.tokenRule });
|
|
69
|
+
return {
|
|
70
|
+
authorizeLimiter,
|
|
71
|
+
registerLimiter,
|
|
72
|
+
tokenLimiter,
|
|
73
|
+
authorizeIpMiddleware: ipRateLimitMiddleware(authorizeLimiter, trustProxy),
|
|
74
|
+
registerIpMiddleware: ipRateLimitMiddleware(registerLimiter, trustProxy),
|
|
75
|
+
tokenIpMiddleware: ipRateLimitMiddleware(tokenLimiter, trustProxy),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function metadataString(meta, key) {
|
|
2
|
+
if (typeof meta !== "object" || meta === null)
|
|
3
|
+
return undefined;
|
|
4
|
+
const value = meta[key];
|
|
5
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
6
|
+
}
|
|
7
|
+
export function conversationScopeIdFromRequestMeta(meta) {
|
|
8
|
+
return metadataString(meta, "openai/session");
|
|
9
|
+
}
|