farming-code 2.2.6
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 +287 -0
- package/README.zh_cn.md +329 -0
- package/SECURITY.md +29 -0
- package/THIRD_PARTY_NOTICES.md +106 -0
- package/backend/acp/client-services.js +312 -0
- package/backend/acp/patch-decisions.js +137 -0
- package/backend/acp/permission-security.js +108 -0
- package/backend/acp-runtime.js +1144 -0
- package/backend/acp-session-state.js +448 -0
- package/backend/acp-transcript.js +169 -0
- package/backend/agent-activity.js +186 -0
- package/backend/agent-env.js +250 -0
- package/backend/agent-json-stream.js +268 -0
- package/backend/agent-manager.js +4259 -0
- package/backend/agent-memory-report.js +583 -0
- package/backend/agent-order.js +162 -0
- package/backend/agent-provider-session.js +287 -0
- package/backend/agent-session-history.js +888 -0
- package/backend/app-server-api.js +917 -0
- package/backend/async-cache.js +94 -0
- package/backend/auth.js +178 -0
- package/backend/claude-settings.js +121 -0
- package/backend/cli-agents.js +484 -0
- package/backend/codex-app-server-home.js +39 -0
- package/backend/codex-app-server-runtime.js +901 -0
- package/backend/codex-context-window.js +189 -0
- package/backend/codex-models.js +229 -0
- package/backend/codex-rollout-follower.js +243 -0
- package/backend/codex-session-history.js +553 -0
- package/backend/codex-transcript-sanitizer.js +103 -0
- package/backend/codex-transcript.js +2341 -0
- package/backend/command-runner-child.js +67 -0
- package/backend/config-manager.js +815 -0
- package/backend/control-api.js +151 -0
- package/backend/data/chinese-poetic-words.json +8223 -0
- package/backend/data/poetic-word-sources/china.json +49209 -0
- package/backend/data/poetic-word-sources/india.json +9763 -0
- package/backend/data/poetic-word-sources/japan.json +8455 -0
- package/backend/executable-discovery.js +207 -0
- package/backend/farming-app-cli.js +790 -0
- package/backend/farming-cli.js +400 -0
- package/backend/farming-session-store.js +373 -0
- package/backend/haiku-token.js +772 -0
- package/backend/index-html.js +49 -0
- package/backend/input-parts.js +54 -0
- package/backend/input-routing.js +24 -0
- package/backend/json-cli-runtime.js +161 -0
- package/backend/local-session-engine.js +620 -0
- package/backend/main-agent-skills.js +292 -0
- package/backend/main-page-session.js +119 -0
- package/backend/native-pty-host-client.js +516 -0
- package/backend/native-pty-host-path.js +22 -0
- package/backend/native-pty-host.js +816 -0
- package/backend/native-session-engine.js +196 -0
- package/backend/network.js +23 -0
- package/backend/npm-update-helper.js +196 -0
- package/backend/packaged-node-pty.js +79 -0
- package/backend/provider-session-id.js +47 -0
- package/backend/qr-share-tickets.js +100 -0
- package/backend/review-diff-router.js +180 -0
- package/backend/review-diff-service.js +1270 -0
- package/backend/review-session-router.js +74 -0
- package/backend/review-session-service.js +432 -0
- package/backend/review-session-store.js +144 -0
- package/backend/review-state-router.js +116 -0
- package/backend/review-state-store.js +287 -0
- package/backend/run-history-store.js +70 -0
- package/backend/server.js +2446 -0
- package/backend/session-engine-bridge.js +110 -0
- package/backend/session-engine-router.js +66 -0
- package/backend/session-engine.js +39 -0
- package/backend/shell-busy-integration.js +472 -0
- package/backend/slash-command-discovery.js +296 -0
- package/backend/storage-layout.js +101 -0
- package/backend/system-monitor.js +77 -0
- package/backend/terminal-runtime-cleanup.js +80 -0
- package/backend/terminal-screen-state.js +240 -0
- package/backend/terminal-screen-worker-pool.js +165 -0
- package/backend/terminal-screen-worker-thread.js +161 -0
- package/backend/terminal-screen-worker.js +255 -0
- package/backend/terminal-status.js +356 -0
- package/backend/theme-manager.js +145 -0
- package/backend/update-service.js +1183 -0
- package/backend/usage-forecast.js +86 -0
- package/backend/usage-monitor.js +1357 -0
- package/backend/workspace-discovery.js +311 -0
- package/backend/workspace-file-router.js +431 -0
- package/backend/workspace-file-service.js +2765 -0
- package/bin/farming +5 -0
- package/config/farming.deploy.env.example +13 -0
- package/config/farming.install.env.example +17 -0
- package/dist/assets/App-BrP-ENHg.css +1 -0
- package/dist/assets/App-Dza5yEDe.js +124 -0
- package/dist/assets/FileEditorMarkdownPreview-DRDNQ8mX.css +1 -0
- package/dist/assets/FileEditorMarkdownPreview-elKWc8Im.js +404 -0
- package/dist/assets/FileEditorPane-BQLocXOp.js +5 -0
- package/dist/assets/IconGlyphs-RkMAdBXF.js +1 -0
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/ProjectFilesSection-lS1azbgj.js +12 -0
- package/dist/assets/ReviewPage-DgnmgU2T.js +3 -0
- package/dist/assets/abap-Cc5D5h5i.js +1 -0
- package/dist/assets/abnfDiagram-VRR7QNED-BgawzDQT.js +1 -0
- package/dist/assets/apex-BKopwLmx.js +1 -0
- package/dist/assets/api-D1lyBYIQ.js +1 -0
- package/dist/assets/arc-CWoVlxJw.js +1 -0
- package/dist/assets/architecture-TIHT7OUA-CbJBFh3w.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-DUShwPg0.js +36 -0
- package/dist/assets/array-HeX70jSN.js +1 -0
- package/dist/assets/azcli-DI-C34WA.js +1 -0
- package/dist/assets/bat-Cbp6u42z.js +1 -0
- package/dist/assets/bicep-4QA1jTCM.js +2 -0
- package/dist/assets/blockDiagram-677ZJIJ3-CeGZviXR.js +132 -0
- package/dist/assets/c4Diagram-LMCZKHZV-CLhYht6S.js +10 -0
- package/dist/assets/cameligo-Dda_adPs.js +1 -0
- package/dist/assets/channel-Uw90AO0b.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-d5WWh8jo.js +1 -0
- package/dist/assets/chunk-32BRIVSS-LFYpT-Cu.js +1 -0
- package/dist/assets/chunk-52WLFC77-BH6jDw9J.js +10 -0
- package/dist/assets/chunk-5FCAYU7R-C7AmIhYv.js +1 -0
- package/dist/assets/chunk-5HE753X5-C8cXaouP.js +1 -0
- package/dist/assets/chunk-5JV3BV7I-C1PtimcA.js +1 -0
- package/dist/assets/chunk-5TONJI2A-_81zUME8.js +2 -0
- package/dist/assets/chunk-5VM5RSS4-Dlw7AXWp.js +15 -0
- package/dist/assets/chunk-7BUUIJ7U-ZBRhjLOh.js +1 -0
- package/dist/assets/chunk-BIQX33UG-CWmzxeAw.js +1 -0
- package/dist/assets/chunk-C7G6YPKG-B_mIUlb7.js +1 -0
- package/dist/assets/chunk-CQNSW5MT-CMayolwI.js +1 -0
- package/dist/assets/chunk-CYSBUYHQ-lSPbrL3Z.js +1 -0
- package/dist/assets/chunk-DECur_0Z.js +1 -0
- package/dist/assets/chunk-EMLP6XTP-D9-jtCnM.js +1 -0
- package/dist/assets/chunk-EX3LRPZG-C63hVuAJ.js +231 -0
- package/dist/assets/chunk-FWX5IMBZ-CboX-WF_.js +2 -0
- package/dist/assets/chunk-HOUHSVGY-BOgSd6Un.js +1 -0
- package/dist/assets/chunk-ICXQ74PX-C0K-pgZt.js +2 -0
- package/dist/assets/chunk-JG7HCLWE-Cib606u_.js +2 -0
- package/dist/assets/chunk-JWPE2WC7-DSyBRaRG.js +1 -0
- package/dist/assets/chunk-KEIR6QF5-CNOHik0T.js +161 -0
- package/dist/assets/chunk-MOJQB5TN-CVMfwN_7.js +88 -0
- package/dist/assets/chunk-MOZMSUNE-D6JeZqmE.js +1 -0
- package/dist/assets/chunk-OGEWGWER-DLT3pxyw.js +1 -0
- package/dist/assets/chunk-OSBZ3O6U-C0W8KSeg.js +1 -0
- package/dist/assets/chunk-PUDLZKDR-Cd079yIQ.js +156 -0
- package/dist/assets/chunk-Q4XR5HBZ-D0jHa6SO.js +70 -0
- package/dist/assets/chunk-QBLGF6JB-p4omp7uO.js +1 -0
- package/dist/assets/chunk-R7FJI6CG-CZ_p9hSr.js +1 -0
- package/dist/assets/chunk-RYQCIY6F-CZA9pvFX.js +1 -0
- package/dist/assets/chunk-U6XO7XAA-CcXKsWxp.js +2 -0
- package/dist/assets/chunk-V7JOEXUC-CVDtR75H.js +206 -0
- package/dist/assets/chunk-VAUOI2AC-B-W2_9Ot.js +1 -0
- package/dist/assets/chunk-VR4S4FIN-FD3kWh32.js +1 -0
- package/dist/assets/chunk-WYO6CB5R-C2bGaS5r.js +127 -0
- package/dist/assets/chunk-XXDRQBXY-BBXwjhUx.js +1 -0
- package/dist/assets/chunk-Y2CYZVJY-Di0sYzi1.js +1 -0
- package/dist/assets/chunk-YOTPTUD7-BXHmEk89.js +1 -0
- package/dist/assets/chunk-ZGVPDNZ5-ymgts0zo.js +62 -0
- package/dist/assets/chunk-ZIRB5QZD-DncwlQQc.js +32 -0
- package/dist/assets/classDiagram-OUVF2IWQ-DKW_dtku.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-C8Fi7-yv.js +1 -0
- package/dist/assets/clojure-CvY8A83L.js +1 -0
- package/dist/assets/code-dark-Cjb1QGhu.css +1 -0
- package/dist/assets/code-mobile-3C2Rr-CN.css +1 -0
- package/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/assets/coffee-4LX2Sv8A.js +1 -0
- package/dist/assets/core-ZlAPicox.js +3 -0
- package/dist/assets/cose-bilkent-JH36ORCC-BNIAz0nN.js +1 -0
- package/dist/assets/cpp-D4AzSV28.js +1 -0
- package/dist/assets/csharp-C4nWN4Yd.js +1 -0
- package/dist/assets/csp-CiEaaS5Z.js +1 -0
- package/dist/assets/css-DXxBRsbk.js +3 -0
- package/dist/assets/css.worker-DyDu5ynT.js +89 -0
- package/dist/assets/cssMode-DDWxTPm_.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-DgXGHlRt.js +1 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-CwpobXIl.js +62 -0
- package/dist/assets/cypher-DOMzqyFA.js +1 -0
- package/dist/assets/cytoscape.esm-Cl8iC3D7.js +321 -0
- package/dist/assets/dagre-DXlcHgr3.js +1 -0
- package/dist/assets/dagre-VKFMJZFB-Dkhlfjna.js +4 -0
- package/dist/assets/dart-BWS7MXt_.js +1 -0
- package/dist/assets/defaultLocale-GJwWH1Jr.js +1 -0
- package/dist/assets/diagram-FQU43EPY-hA8dicp6.js +3 -0
- package/dist/assets/diagram-G47NLZAW-BTY6JTzO.js +24 -0
- package/dist/assets/diagram-NH7WQ7WH-xkaHHX9M.js +24 -0
- package/dist/assets/diagram-OA4YK3LP-gk_fg9UU.js +30 -0
- package/dist/assets/diagram-WEI45ONY-BvC8xd6T.js +41 -0
- package/dist/assets/dist-ClAL-Tv5.js +1 -0
- package/dist/assets/dockerfile-Baf4U3xT.js +1 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-CR7RaNat.js +1 -0
- package/dist/assets/ecl-CT7udlkQ.js +1 -0
- package/dist/assets/editor-CtbFZlk0.css +1 -0
- package/dist/assets/editor.api2-B9h6iFPK.js +872 -0
- package/dist/assets/editor.worker-Dpt_xPrs.js +26 -0
- package/dist/assets/elixir-CIbAZw5l.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-_M-JFPbj.js +85 -0
- package/dist/assets/eventmodeling-45OFAUF4-DXYTQ2nt.js +1 -0
- package/dist/assets/file-icons-EFUGSSwf.js +1 -0
- package/dist/assets/flow9-Dqiw45WV.js +1 -0
- package/dist/assets/flowDiagram-23GEKE2U-DAiS5Y7G.js +1 -0
- package/dist/assets/freemarker2-QBsTERH-.js +3 -0
- package/dist/assets/fsharp-E8E2L9jU.js +1 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-Bl8P1yf_.js +292 -0
- package/dist/assets/gitGraph-TEB2WS4Q-CzTBjEvV.js +1 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-DoHa5ysz.js +106 -0
- package/dist/assets/go-CouVSN4D.js +1 -0
- package/dist/assets/graphlib-CbSvZcZU.js +1 -0
- package/dist/assets/graphql-a6h6h5-t.js +1 -0
- package/dist/assets/handlebars-CuoxPo5A.js +1 -0
- package/dist/assets/hcl-vso3e6N-.js +1 -0
- package/dist/assets/html-gX5PEu0Q.js +1 -0
- package/dist/assets/html.worker-IWNXhnIC.js +502 -0
- package/dist/assets/htmlMode-DIWUbUxd.js +1 -0
- package/dist/assets/index-BpHPeJf0.js +10 -0
- package/dist/assets/info-DKCQHKI2-DznP7j3s.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-DSFcSuUs.js +2 -0
- package/dist/assets/ini-SwZZkotR.js +1 -0
- package/dist/assets/init-BPLPMQ3Y.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-DdkqullI.js +70 -0
- package/dist/assets/java-CtRLC4_3.js +1 -0
- package/dist/assets/javascript-BYKGIUGs.js +1 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-B4hRnQJr.js +139 -0
- package/dist/assets/json.worker-c4h5s80L.js +58 -0
- package/dist/assets/jsonMode-AFmQQP6u.js +7 -0
- package/dist/assets/jsx-runtime-BthL93pI.js +1 -0
- package/dist/assets/julia-CuJWFKQH.js +1 -0
- package/dist/assets/kanban-definition-HUTT4EX6-tm2FZB2E.js +89 -0
- package/dist/assets/katex-C8DPyI6s.js +257 -0
- package/dist/assets/kotlin-B_kBhsre.js +1 -0
- package/dist/assets/less-CtrHIfz3.js +2 -0
- package/dist/assets/lexon-yVt1pJLu.js +1 -0
- package/dist/assets/line-CmsjK4kn.js +1 -0
- package/dist/assets/linear-Dld3_ERu.js +1 -0
- package/dist/assets/liquid-DBIl-f0z.js +1 -0
- package/dist/assets/lspLanguageFeatures-DK6tqicV.js +4 -0
- package/dist/assets/lua-prOwgJ4U.js +1 -0
- package/dist/assets/m3-DhrdTQ84.js +1 -0
- package/dist/assets/main-DTJwH51M.css +1 -0
- package/dist/assets/map-LZWWoeWa.js +1 -0
- package/dist/assets/markdown-DoI5HwSM.js +1 -0
- package/dist/assets/mdx-DS-bVtZN.js +1 -0
- package/dist/assets/mermaid-parser.core-BQtepoLd.js +4 -0
- package/dist/assets/mermaid.core-C7UT_EEL.js +11 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-DplfjGms.js +96 -0
- package/dist/assets/mips-Dye5jsBU.js +1 -0
- package/dist/assets/monaco.contribution-CyLosfZI.js +2 -0
- package/dist/assets/msdax-TkNOyIL8.js +1 -0
- package/dist/assets/mysql-CEc-RKZF.js +1 -0
- package/dist/assets/objective-c-CqqCsQz0.js +1 -0
- package/dist/assets/ordinal-BLrOss5K.js +1 -0
- package/dist/assets/packet-7NZHBO7P-BDEPOPha.js +1 -0
- package/dist/assets/pascal-DO_pj8yg.js +1 -0
- package/dist/assets/pascaligo-1cbdZdF3.js +1 -0
- package/dist/assets/path-YdFzr2W6.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-lu3SdkQs.js +1 -0
- package/dist/assets/perl-B_N3PYfC.js +1 -0
- package/dist/assets/pgsql-9iYk1FQ7.js +1 -0
- package/dist/assets/php-rO2sgoUM.js +1 -0
- package/dist/assets/pie-RZYD4A2V-DWIrwPJQ.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-3fHbmDf9.js +39 -0
- package/dist/assets/pla-Cbgv60kq.js +1 -0
- package/dist/assets/postiats-y6xrhy_M.js +1 -0
- package/dist/assets/powerquery-BaD8gWNE.js +1 -0
- package/dist/assets/powershell-BMhG4JVe.js +1 -0
- package/dist/assets/preload-helper-mJowh_hw.js +1 -0
- package/dist/assets/protobuf-CdOP5kN3.js +2 -0
- package/dist/assets/pug-Ck60hNF9.js +1 -0
- package/dist/assets/python-C93q3xXz.js +1 -0
- package/dist/assets/qoder-C9LmmOSf.svg +1 -0
- package/dist/assets/qoder-Cf9gl0Y5.svg +1 -0
- package/dist/assets/qoder-gHCinseV.svg +1 -0
- package/dist/assets/qrcode-DV-_rjU8.js +3 -0
- package/dist/assets/qsharp-BcaKFfP-.js +1 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-a5qoWz-X.js +7 -0
- package/dist/assets/r-rFNes0iK.js +1 -0
- package/dist/assets/radar-I7S5WNFK-B7OaD8vp.js +1 -0
- package/dist/assets/railroad-3IZDKUUU-BXW2nuCA.js +1 -0
- package/dist/assets/railroad-abnf-AHOZXSZD-Buw9QG2r.js +1 -0
- package/dist/assets/railroad-ebnf-EBAXGLYW-BjSi4sWJ.js +1 -0
- package/dist/assets/railroad-peg-LSFZ7HO6-DN1wIVhS.js +1 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-D2TOuXW9.js +1 -0
- package/dist/assets/razor-CBifNGXO.js +1 -0
- package/dist/assets/react-dom-gtU6X-Hj.js +1 -0
- package/dist/assets/redis-DkpQ3K6G.js +1 -0
- package/dist/assets/redshift-Di9N5TI3.js +1 -0
- package/dist/assets/requirementDiagram-TGXJPOKE-LQBWpUvd.js +84 -0
- package/dist/assets/restructuredtext-By5ZzLt6.js +1 -0
- package/dist/assets/review-BcnwQtJv.css +1 -0
- package/dist/assets/rough.esm-c4PR5shF.js +1 -0
- package/dist/assets/ruby-fF5zGiLp.js +1 -0
- package/dist/assets/rust-C5b3AYY6.js +1 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-B1ohYoyK.js +40 -0
- package/dist/assets/sb-CD07UNRs.js +1 -0
- package/dist/assets/scala-jtn1ip9G.js +1 -0
- package/dist/assets/scheme-C4vqMkn_.js +1 -0
- package/dist/assets/scss-I4Glxjbz.js +3 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-C3vM-hMq.js +162 -0
- package/dist/assets/shell-DubUcuns.js +1 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-daTB6OcF.js +1 -0
- package/dist/assets/solidity-CNy2KSl2.js +1 -0
- package/dist/assets/sophia-D9_URt84.js +1 -0
- package/dist/assets/sparql-DviXpm4C.js +1 -0
- package/dist/assets/sql-vDRbAZgK.js +1 -0
- package/dist/assets/src-WBW1QxJt.js +1 -0
- package/dist/assets/st-CnpnRqA7.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-BvFhOryI.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-WMrz4PNo.js +1 -0
- package/dist/assets/swift-D_g8Ganz.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-DKF_b-2s.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-BGswC9oC.js +8 -0
- package/dist/assets/systemverilog-OuZa5h1M.js +1 -0
- package/dist/assets/tcl-DBm9ucsV.js +1 -0
- package/dist/assets/timeline-definition-FHXFAJF6-vAs11ux_.js +120 -0
- package/dist/assets/tokens-BwenNn5Q.css +1 -0
- package/dist/assets/treeView-QDETBFTQ-BVfICaZQ.js +1 -0
- package/dist/assets/treemap-6X3UGDF4-oWHPqo17.js +1 -0
- package/dist/assets/ts.worker-BwM5Ha3L.js +67719 -0
- package/dist/assets/tsMode-DGZTlTj8.js +11 -0
- package/dist/assets/twig-BRzEqX5Y.js +1 -0
- package/dist/assets/typescript-KJKfYO7K.js +1 -0
- package/dist/assets/typespec-D4ZgGeX8.js +1 -0
- package/dist/assets/useWorkspaceMenuKeyboard-CneKAZUJ.js +1 -0
- package/dist/assets/vb-DcP4s6WS.js +1 -0
- package/dist/assets/vennDiagram-L72KCM5P-BybTX_9B.js +34 -0
- package/dist/assets/wardley-OPB4EBWU-Dg8t5y3s.js +1 -0
- package/dist/assets/wardleyDiagram-EHGQE667-CicUmMBR.js +78 -0
- package/dist/assets/wgsl-CnRJ_QUf.js +298 -0
- package/dist/assets/workers-BSQRIkqa.js +1 -0
- package/dist/assets/workspace-view-state-CTyDzk2D.js +1 -0
- package/dist/assets/xml-C8FAcN6j.js +1 -0
- package/dist/assets/xychartDiagram-FW5EYKEG-BhWDyCX-.js +7 -0
- package/dist/assets/yaml-BQ4NrRhG.js +1 -0
- package/dist/assets/zsh-CLpveKlF.svg +1 -0
- package/dist/assets/zsh-FxSpMPbz.svg +1 -0
- package/dist/farming-2/app-icon-v2-180.png +0 -0
- package/dist/farming-2/app-icon-v2-192.png +0 -0
- package/dist/farming-2/app-icon-v2-512.png +0 -0
- package/dist/farming-2/app-icon-v2-maskable-512.png +0 -0
- package/dist/farming-2/app-icon-v2-master.png +0 -0
- package/dist/farming-2/favicon-v2-16.png +0 -0
- package/dist/farming-2/favicon-v2-32.png +0 -0
- package/dist/farming-2/favicon-v2-48.png +0 -0
- package/dist/farming-2/favicon-v2-64.png +0 -0
- package/dist/farming-2/favicon-v2.ico +0 -0
- package/dist/farming-2/favicon.ico +0 -0
- package/dist/farming-2/github-social-preview.png +0 -0
- package/dist/farming-2/images/avatar-watercolor-v1-bee-garden.png +0 -0
- package/dist/farming-2/images/avatar-watercolor-v2.png +0 -0
- package/dist/farming-2/images/avatar-watercolor-v3.png +0 -0
- package/dist/farming-2/legacy-icons-v1/favicon.ico +1 -0
- package/dist/farming-2/legacy-icons-v1/logo-16.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-180.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-192.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-32.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-48.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-512.png +0 -0
- package/dist/farming-2/legacy-icons-v1/logo-64.png +0 -0
- package/dist/farming-2/logo-16.png +0 -0
- package/dist/farming-2/logo-180.png +0 -0
- package/dist/farming-2/logo-192.png +0 -0
- package/dist/farming-2/logo-32.png +0 -0
- package/dist/farming-2/logo-48.png +0 -0
- package/dist/farming-2/logo-512.png +0 -0
- package/dist/farming-2/logo-64.png +0 -0
- package/dist/farming-2/site.webmanifest +27 -0
- package/dist/farming-2/style_capsules/watercolor-pastoral.json +94 -0
- package/dist/index.html +27 -0
- package/frontend/ghostty-loader.js +24 -0
- package/frontend/runtime-paths.js +28 -0
- package/frontend/session-bridge.js +82 -0
- package/frontend/session-modal-bridge.js +331 -0
- package/frontend/skin-bridge.js +25 -0
- package/frontend/skins/crt/app.js +6940 -0
- package/frontend/skins/crt/assets/branding/farming-crt-icon.svg +11 -0
- package/frontend/skins/crt/assets/branding/farming-crt-logo-v1.png +0 -0
- package/frontend/skins/crt/assets/effects/phosphor-noise.svg +11 -0
- package/frontend/skins/crt/assets/fonts/departure-mono/DepartureMonoNerdFontMono-Regular.otf +0 -0
- package/frontend/skins/crt/assets/fonts/departure-mono/LICENSE +93 -0
- package/frontend/skins/crt/effects.js +8 -0
- package/frontend/skins/crt/index.html +1712 -0
- package/frontend/skins/crt/styles/billing.css +1003 -0
- package/frontend/skins/crt/styles/effects.css +171 -0
- package/frontend/skins/crt/styles/history.css +215 -0
- package/frontend/skins/crt/styles/monochrome-green.css +509 -0
- package/frontend/skins/crt/styles/search.css +271 -0
- package/frontend/terminal-bridge.js +192 -0
- package/frontend/theme-loader.js +84 -0
- package/frontend/themes/terminal/theme.json +24 -0
- package/frontend/vendor/ghostty-web/LICENSE +21 -0
- package/frontend/vendor/ghostty-web/__vite-browser-external-2447137e.js +4 -0
- package/frontend/vendor/ghostty-web/ghostty-vt.wasm +0 -0
- package/frontend/vendor/ghostty-web/ghostty-web.js +2963 -0
- package/frontend/vendor/ghostty-web/ghostty-web.umd.cjs +13 -0
- package/frontend/vendor/ghostty-web/index.d.ts +1842 -0
- package/index.html +23 -0
- package/package.json +144 -0
- package/scripts/sync-ghostty-vendor.js +66 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
function agentKindForCommand(command) {
|
|
2
|
+
const executable = String(command || '')
|
|
3
|
+
.trim()
|
|
4
|
+
.split(/\s+/)
|
|
5
|
+
.find(token => token !== 'env' && !/^[A-Za-z_][A-Za-z0-9_]*=/.test(token));
|
|
6
|
+
const basename = (executable || '').split('/').pop() || '';
|
|
7
|
+
if (basename === 'codex') return 'codex';
|
|
8
|
+
if (basename === 'claude') return 'claude';
|
|
9
|
+
if (['bash', 'zsh', 'sh', 'fish'].includes(basename)) return 'shell';
|
|
10
|
+
return executable ? 'agent' : null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function currentTerminalText(agent) {
|
|
14
|
+
if (!agent) return '';
|
|
15
|
+
const previewText = typeof agent.previewText === 'string' ? agent.previewText : '';
|
|
16
|
+
if (previewText.trim()) return previewText.toLowerCase();
|
|
17
|
+
return String(agent.output || '').slice(-1800).toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function lastIndexOfAny(text, needles) {
|
|
21
|
+
return needles.reduce((last, needle) => Math.max(last, text.lastIndexOf(needle)), -1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function lastCodexIdleFooterIndex(text) {
|
|
25
|
+
const matches = Array.from(text.matchAll(/(?:^|\n)\s*(?:gpt|codex)[^\n]*(?:·|•)\s*(?:~|\/)[^\n]*$/gim));
|
|
26
|
+
const lastMatch = matches.length > 0 ? matches[matches.length - 1] : undefined;
|
|
27
|
+
return lastMatch && typeof lastMatch.index === 'number' ? lastMatch.index : -1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function codexActiveIndex(text) {
|
|
31
|
+
const activeTextIndex = lastIndexOfAny(text, [
|
|
32
|
+
'pursuing goal',
|
|
33
|
+
'esc to interrupt',
|
|
34
|
+
'press esc to interrupt',
|
|
35
|
+
'reconnecting',
|
|
36
|
+
'/stop to close',
|
|
37
|
+
'background terminal running',
|
|
38
|
+
]);
|
|
39
|
+
const workingIndex = /\bworking\b/.test(text) ? text.lastIndexOf('working') : -1;
|
|
40
|
+
const stepMatches = Array.from(text.matchAll(/step\s+\d+\s*\/\s*\d+/g));
|
|
41
|
+
const lastStepMatch = stepMatches.length > 0 ? stepMatches[stepMatches.length - 1] : undefined;
|
|
42
|
+
const stepIndex = lastStepMatch && typeof lastStepMatch.index === 'number' ? lastStepMatch.index : -1;
|
|
43
|
+
return Math.max(activeTextIndex, workingIndex, stepIndex);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function codexKindIndex(text) {
|
|
47
|
+
const codexSpecificIndex = lastIndexOfAny(text, [
|
|
48
|
+
'pursuing goal',
|
|
49
|
+
'reconnecting',
|
|
50
|
+
'/stop to close',
|
|
51
|
+
'background terminal running',
|
|
52
|
+
'messages to be submitted after next tool call',
|
|
53
|
+
'stream disconnected before completion',
|
|
54
|
+
]);
|
|
55
|
+
const workingIndex = /\bworking\b/.test(text) ? text.lastIndexOf('working') : -1;
|
|
56
|
+
const stepMatches = Array.from(text.matchAll(/step\s+\d+\s*\/\s*\d+/g));
|
|
57
|
+
const lastStepMatch = stepMatches.length > 0 ? stepMatches[stepMatches.length - 1] : undefined;
|
|
58
|
+
const stepIndex = lastStepMatch && typeof lastStepMatch.index === 'number' ? lastStepMatch.index : -1;
|
|
59
|
+
return Math.max(codexSpecificIndex, workingIndex, stepIndex);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function codexBlockedIndex(text) {
|
|
63
|
+
return lastIndexOfAny(text, [
|
|
64
|
+
'goal blocked',
|
|
65
|
+
'input exceeds the context window',
|
|
66
|
+
'please adjust your input and try again',
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function titleWithoutActivityPrefix(title) {
|
|
71
|
+
return String(title || '')
|
|
72
|
+
.trim()
|
|
73
|
+
.replace(/^[\s**✳✱✲✶·•:.\u2800-\u28FF]+/u, '')
|
|
74
|
+
.replace(/\s+/g, ' ')
|
|
75
|
+
.toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function activeTerminalTitleKind(agent) {
|
|
79
|
+
const title = typeof agent.sessionTitle === 'string' ? agent.sessionTitle.trim() : '';
|
|
80
|
+
if (/^[\u2800-\u28ff]/u.test(title)) return 'codex';
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function genericTerminalTitleKind(agent) {
|
|
85
|
+
const normalized = titleWithoutActivityPrefix(agent && agent.sessionTitle);
|
|
86
|
+
if (!normalized) return null;
|
|
87
|
+
if (/\bclaude(?:\s+code)?\b/.test(normalized)) return 'claude';
|
|
88
|
+
if (/\bcodex\b/.test(normalized)) return 'codex';
|
|
89
|
+
if (/^(?:bash|zsh|sh|fish)(?:\s|$)/.test(normalized)) return 'shell';
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function lastMatchIndex(text, pattern) {
|
|
94
|
+
const matches = Array.from(text.matchAll(pattern));
|
|
95
|
+
const lastMatch = matches.length > 0 ? matches[matches.length - 1] : undefined;
|
|
96
|
+
return lastMatch && typeof lastMatch.index === 'number' ? lastMatch.index : -1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function latestTerminalOutputKind(text) {
|
|
100
|
+
const candidates = [];
|
|
101
|
+
const codexIndex = Math.max(
|
|
102
|
+
lastCodexIdleFooterIndex(text),
|
|
103
|
+
codexKindIndex(text),
|
|
104
|
+
lastMatchIndex(text, /(?:^|\n)\s*›\s/g)
|
|
105
|
+
);
|
|
106
|
+
if (codexIndex >= 0) candidates.push({ kind: 'codex', index: codexIndex });
|
|
107
|
+
|
|
108
|
+
const claudeIndex = Math.max(
|
|
109
|
+
lastIndexOfAny(text, ['claude code']),
|
|
110
|
+
lastMatchIndex(text, /(?:thinking|claude)[\s\S]*(?:esc|escape|ctrl\+c|ctrl-c) to interrupt/g)
|
|
111
|
+
);
|
|
112
|
+
if (claudeIndex >= 0) candidates.push({ kind: 'claude', index: claudeIndex });
|
|
113
|
+
|
|
114
|
+
const shellIndex = lastMatchIndex(text, /(?:^|\n)\s*(?:[\w./~:@-]+\s*)?[$%#]\s*$/gm);
|
|
115
|
+
if (shellIndex >= 0) candidates.push({ kind: 'shell', index: shellIndex });
|
|
116
|
+
|
|
117
|
+
const latest = candidates.sort((a, b) => b.index - a.index)[0];
|
|
118
|
+
return latest ? latest.kind : null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function inferAgentKind(agent) {
|
|
122
|
+
if (!agent) return null;
|
|
123
|
+
return activeTerminalTitleKind(agent)
|
|
124
|
+
|| latestTerminalOutputKind(currentTerminalText(agent))
|
|
125
|
+
|| (agent.terminalStatus && agent.terminalStatus.kind !== 'unknown' ? agent.terminalStatus.kind : null)
|
|
126
|
+
|| (agent.terminalBusy === true ? 'shell' : null)
|
|
127
|
+
|| genericTerminalTitleKind(agent)
|
|
128
|
+
|| agentKindForCommand(agent.command);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function isAgentTerminalBusy(agent) {
|
|
132
|
+
if (agent && agent.terminalStatus) {
|
|
133
|
+
if (agent.terminalStatus.activity === 'busy') return true;
|
|
134
|
+
if (agent.terminalStatus.activity === 'idle' || agent.terminalStatus.activity === 'exited') return false;
|
|
135
|
+
}
|
|
136
|
+
return agent && agent.terminalBusy === true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function isCodexRestartBlocking(agent) {
|
|
140
|
+
const output = currentTerminalText(agent);
|
|
141
|
+
if (!output) return false;
|
|
142
|
+
if (output.includes('messages to be submitted after next tool call')) return true;
|
|
143
|
+
|
|
144
|
+
const activeIndex = codexActiveIndex(output);
|
|
145
|
+
if (activeIndex < 0) return false;
|
|
146
|
+
|
|
147
|
+
const blockedIndex = codexBlockedIndex(output);
|
|
148
|
+
if (blockedIndex >= activeIndex) return false;
|
|
149
|
+
|
|
150
|
+
return lastCodexIdleFooterIndex(output) <= activeIndex;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isClaudeRestartBlocking(agent) {
|
|
154
|
+
const output = currentTerminalText(agent);
|
|
155
|
+
return (
|
|
156
|
+
output.includes('esc to interrupt') ||
|
|
157
|
+
output.includes('escape to interrupt') ||
|
|
158
|
+
output.includes('ctrl+c to interrupt') ||
|
|
159
|
+
output.includes('ctrl-c to interrupt') ||
|
|
160
|
+
output.includes('press esc to interrupt')
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function isRecoverableEngineAgent(agent) {
|
|
165
|
+
return agent && agent.engineName === 'native';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function isRestartBlockingAgent(agent) {
|
|
169
|
+
if (!agent || agent.isMain === true || agent.archived === true) return false;
|
|
170
|
+
if (agent.status === 'pending') return true;
|
|
171
|
+
if (agent.status !== 'running') return false;
|
|
172
|
+
if (isRecoverableEngineAgent(agent)) return false;
|
|
173
|
+
if (isAgentTerminalBusy(agent)) return true;
|
|
174
|
+
|
|
175
|
+
const kind = inferAgentKind(agent);
|
|
176
|
+
if (kind === 'shell') return false;
|
|
177
|
+
if (kind === 'codex') return isCodexRestartBlocking(agent);
|
|
178
|
+
if (kind === 'claude') return isClaudeRestartBlocking(agent);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
agentKindForCommand,
|
|
184
|
+
isRecoverableEngineAgent,
|
|
185
|
+
isRestartBlockingAgent,
|
|
186
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const SHELL_ENV_BEGIN = '__FARMING_AGENT_ENV_BEGIN__';
|
|
7
|
+
const SHELL_ENV_END = '__FARMING_AGENT_ENV_END__';
|
|
8
|
+
const DEFAULT_SHELL_ENV_TIMEOUT_MS = 2500;
|
|
9
|
+
|
|
10
|
+
function isCatPager(value) {
|
|
11
|
+
const text = String(value || '').trim();
|
|
12
|
+
if (!text) return false;
|
|
13
|
+
return /^(?:\/[^\s]+\/)?cat(?:\s|$)/.test(text);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function scrubNonInteractivePagerEnv(env) {
|
|
17
|
+
const next = env || {};
|
|
18
|
+
if (next.FARMING_PRESERVE_AGENT_CAT_PAGER === '1') {
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (isCatPager(next.PAGER)) delete next.PAGER;
|
|
23
|
+
if (isCatPager(next.GIT_PAGER)) delete next.GIT_PAGER;
|
|
24
|
+
return next;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function shellQuote(value) {
|
|
28
|
+
return `'${String(value).replace(/'/g, "'\\''")}'`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeTimeoutMs(value, fallback = DEFAULT_SHELL_ENV_TIMEOUT_MS) {
|
|
32
|
+
const parsed = Math.floor(Number(value));
|
|
33
|
+
if (!Number.isFinite(parsed)) return fallback;
|
|
34
|
+
return Math.max(250, Math.min(parsed, 15000));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function defaultShell(processEnv = process.env) {
|
|
38
|
+
if (processEnv.SHELL) return processEnv.SHELL;
|
|
39
|
+
if (process.platform === 'win32') return '';
|
|
40
|
+
if (fsExists('/bin/bash')) return '/bin/bash';
|
|
41
|
+
return '/bin/sh';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function fsExists(filePath) {
|
|
45
|
+
try {
|
|
46
|
+
return fs.existsSync(filePath);
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function shellEnvArgs(shell, command) {
|
|
53
|
+
const name = path.basename(String(shell || '')).toLowerCase();
|
|
54
|
+
if (name === 'bash' || name === 'zsh' || name === 'fish' || name === 'ksh') {
|
|
55
|
+
return ['-lic', command];
|
|
56
|
+
}
|
|
57
|
+
if (process.platform === 'win32' && (name === 'cmd.exe' || name === 'cmd')) {
|
|
58
|
+
return ['/d', '/s', '/c', command];
|
|
59
|
+
}
|
|
60
|
+
return ['-lc', command];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function buildShellEnvCommand(nodePath = process.execPath) {
|
|
64
|
+
const script = 'process.stdout.write(JSON.stringify(process.env))';
|
|
65
|
+
return [
|
|
66
|
+
`printf '\\n${SHELL_ENV_BEGIN}\\n'`,
|
|
67
|
+
`${shellQuote(nodePath)} -e ${shellQuote(script)}`,
|
|
68
|
+
`printf '\\n${SHELL_ENV_END}\\n'`,
|
|
69
|
+
].join('; ');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function parseShellEnvOutput(output) {
|
|
73
|
+
const text = Buffer.isBuffer(output) ? output.toString('utf8') : String(output || '');
|
|
74
|
+
const start = text.indexOf(SHELL_ENV_BEGIN);
|
|
75
|
+
const end = text.lastIndexOf(SHELL_ENV_END);
|
|
76
|
+
if (start < 0 || end <= start) return null;
|
|
77
|
+
|
|
78
|
+
const jsonText = text.slice(start + SHELL_ENV_BEGIN.length, end).trim();
|
|
79
|
+
if (!jsonText) return null;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const parsed = JSON.parse(jsonText);
|
|
83
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return null;
|
|
84
|
+
return Object.fromEntries(
|
|
85
|
+
Object.entries(parsed)
|
|
86
|
+
.filter(([key, value]) => typeof key === 'string' && typeof value === 'string')
|
|
87
|
+
);
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function resolveUserShellEnvSync(options = {}) {
|
|
94
|
+
const processEnv = options.processEnv || process.env;
|
|
95
|
+
if (String(processEnv.FARMING_AGENT_SHELL_ENV || '').toLowerCase() === '0' ||
|
|
96
|
+
String(processEnv.FARMING_AGENT_SHELL_ENV || '').toLowerCase() === 'false') {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const shell = options.shell || defaultShell(processEnv);
|
|
101
|
+
if (!shell) return null;
|
|
102
|
+
|
|
103
|
+
const command = options.command || buildShellEnvCommand(options.nodePath || process.execPath);
|
|
104
|
+
const args = options.args || shellEnvArgs(shell, command);
|
|
105
|
+
const timeout = normalizeTimeoutMs(options.timeoutMs ?? processEnv.FARMING_AGENT_SHELL_ENV_TIMEOUT_MS);
|
|
106
|
+
const env = {
|
|
107
|
+
...processEnv,
|
|
108
|
+
FARMING_COLLECT_AGENT_SHELL_ENV: '1',
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const result = spawnSync(shell, args, {
|
|
112
|
+
cwd: options.cwd || processEnv.HOME || os.homedir(),
|
|
113
|
+
env,
|
|
114
|
+
input: '',
|
|
115
|
+
encoding: 'utf8',
|
|
116
|
+
maxBuffer: 1024 * 1024,
|
|
117
|
+
timeout,
|
|
118
|
+
windowsHide: true,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (result.error || result.signal === 'SIGTERM' || result.status === 124) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return parseShellEnvOutput(result.stdout);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const PROCESS_ENV_EXACT_KEYS = new Set([
|
|
129
|
+
'ANTHROPIC_API_KEY',
|
|
130
|
+
'ANTHROPIC_AUTH_TOKEN',
|
|
131
|
+
'ANTHROPIC_BASE_URL',
|
|
132
|
+
'ALL_PROXY',
|
|
133
|
+
'all_proxy',
|
|
134
|
+
'CLAUDE_CONFIG_DIR',
|
|
135
|
+
'CODEX_HOME',
|
|
136
|
+
'OPENCODE_CONFIG_DIR',
|
|
137
|
+
'QODER_CONFIG_DIR',
|
|
138
|
+
'CURL_CA_BUNDLE',
|
|
139
|
+
'DASHSCOPE_API_KEY',
|
|
140
|
+
'EDITOR',
|
|
141
|
+
'FARMING_ANONYMIZE_SHELL_PROMPT',
|
|
142
|
+
'FARMING_PRESERVE_AGENT_CAT_PAGER',
|
|
143
|
+
'FARMING_SHELL_CONTROLLED_PROMPT',
|
|
144
|
+
'GEMINI_API_KEY',
|
|
145
|
+
'GIT_ASKPASS',
|
|
146
|
+
'GITHUB_TOKEN',
|
|
147
|
+
'GITLAB_TOKEN',
|
|
148
|
+
'GPG_TTY',
|
|
149
|
+
'HTTPS_PROXY',
|
|
150
|
+
'https_proxy',
|
|
151
|
+
'HTTP_PROXY',
|
|
152
|
+
'http_proxy',
|
|
153
|
+
'LANG',
|
|
154
|
+
'LC_ALL',
|
|
155
|
+
'LC_CTYPE',
|
|
156
|
+
'NO_PROXY',
|
|
157
|
+
'no_proxy',
|
|
158
|
+
'NODE_EXTRA_CA_CERTS',
|
|
159
|
+
'OPENAI_API_KEY',
|
|
160
|
+
'OPENAI_BASE_URL',
|
|
161
|
+
'OPENAI_MODEL',
|
|
162
|
+
'REQUESTS_CA_BUNDLE',
|
|
163
|
+
'SHELL',
|
|
164
|
+
'SSH_AGENT_PID',
|
|
165
|
+
'SSH_AUTH_SOCK',
|
|
166
|
+
'SSL_CERT_DIR',
|
|
167
|
+
'SSL_CERT_FILE',
|
|
168
|
+
'VISUAL',
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
const PROCESS_ENV_PREFIXES = [
|
|
172
|
+
'ANTHROPIC_',
|
|
173
|
+
'AWS_',
|
|
174
|
+
'AZURE_OPENAI_',
|
|
175
|
+
'CLAUDE_CODE_',
|
|
176
|
+
'DASHSCOPE_',
|
|
177
|
+
'GEMINI_',
|
|
178
|
+
'GITHUB_',
|
|
179
|
+
'GITLAB_',
|
|
180
|
+
'GOOGLE_API_',
|
|
181
|
+
'GOOGLE_CLOUD_',
|
|
182
|
+
'LANGCHAIN_',
|
|
183
|
+
'LC_',
|
|
184
|
+
'NPM_CONFIG_',
|
|
185
|
+
'OPENAI_',
|
|
186
|
+
'PIP_',
|
|
187
|
+
'QWEN_',
|
|
188
|
+
'UV_',
|
|
189
|
+
'npm_config_',
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
function shouldOverlayProcessEnv(key) {
|
|
193
|
+
return PROCESS_ENV_EXACT_KEYS.has(key) || PROCESS_ENV_PREFIXES.some(prefix => key.startsWith(prefix));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function buildInteractiveAgentBaseEnv(options = {}) {
|
|
197
|
+
const processEnv = options.processEnv || process.env;
|
|
198
|
+
const shellEnv = options.shellEnv && typeof options.shellEnv === 'object' ? options.shellEnv : null;
|
|
199
|
+
const env = shellEnv ? { ...shellEnv } : { ...processEnv };
|
|
200
|
+
|
|
201
|
+
for (const [key, value] of Object.entries(processEnv)) {
|
|
202
|
+
if (typeof value !== 'string') continue;
|
|
203
|
+
if (!shouldOverlayProcessEnv(key)) continue;
|
|
204
|
+
if (key in env && env[key] !== '') continue;
|
|
205
|
+
env[key] = value;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!env.HOME) env.HOME = processEnv.HOME || os.homedir();
|
|
209
|
+
if (!env.USER && processEnv.USER) env.USER = processEnv.USER;
|
|
210
|
+
if (!env.LOGNAME && processEnv.LOGNAME) env.LOGNAME = processEnv.LOGNAME;
|
|
211
|
+
if (!env.PATH && processEnv.PATH) env.PATH = processEnv.PATH;
|
|
212
|
+
|
|
213
|
+
return env;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function normalizeInteractiveTerminalEnv(env, options = {}) {
|
|
217
|
+
const next = env || {};
|
|
218
|
+
|
|
219
|
+
if (options.stripRuntimeShims !== false) {
|
|
220
|
+
delete next.LD_LIBRARY_PATH;
|
|
221
|
+
}
|
|
222
|
+
if (options.stripNodeOptions !== false) {
|
|
223
|
+
delete next.NODE_OPTIONS;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
delete next.NO_COLOR;
|
|
227
|
+
scrubNonInteractivePagerEnv(next);
|
|
228
|
+
|
|
229
|
+
if (!next.TERM || String(next.TERM).toLowerCase() === 'dumb') {
|
|
230
|
+
next.TERM = 'xterm-256color';
|
|
231
|
+
}
|
|
232
|
+
next.COLORTERM = 'truecolor';
|
|
233
|
+
next.CLICOLOR = next.CLICOLOR || '1';
|
|
234
|
+
next.TERM_PROGRAM = 'farming';
|
|
235
|
+
next.TERM_PROGRAM_VERSION = process.env.npm_package_version || '';
|
|
236
|
+
return next;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
module.exports = {
|
|
240
|
+
SHELL_ENV_BEGIN,
|
|
241
|
+
SHELL_ENV_END,
|
|
242
|
+
buildInteractiveAgentBaseEnv,
|
|
243
|
+
buildShellEnvCommand,
|
|
244
|
+
isCatPager,
|
|
245
|
+
normalizeInteractiveTerminalEnv,
|
|
246
|
+
parseShellEnvOutput,
|
|
247
|
+
resolveUserShellEnvSync,
|
|
248
|
+
scrubNonInteractivePagerEnv,
|
|
249
|
+
shellEnvArgs,
|
|
250
|
+
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
const { buildTranscriptFromEvents } = require('./codex-transcript');
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MAX_EVENTS = 12_000;
|
|
4
|
+
|
|
5
|
+
class JsonlStreamDecoder {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.buffer = '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
push(chunk) {
|
|
11
|
+
this.buffer += Buffer.isBuffer(chunk) ? chunk.toString('utf8') : String(chunk || '');
|
|
12
|
+
const lines = this.buffer.split('\n');
|
|
13
|
+
this.buffer = lines.pop() || '';
|
|
14
|
+
return lines.flatMap(parseJsonLine);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
flush() {
|
|
18
|
+
const trailing = this.buffer;
|
|
19
|
+
this.buffer = '';
|
|
20
|
+
return parseJsonLine(trailing);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function parseJsonLine(line) {
|
|
25
|
+
const text = String(line || '').trim();
|
|
26
|
+
if (!text) return [];
|
|
27
|
+
try {
|
|
28
|
+
return [JSON.parse(text)];
|
|
29
|
+
} catch {
|
|
30
|
+
// Coding-agent CLIs occasionally print update notices or diagnostics to
|
|
31
|
+
// stdout. They should remain visible in the terminal, but must not poison
|
|
32
|
+
// the structured chat stream.
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function itemEvent(type, turnId, item) {
|
|
38
|
+
return { type, turn_id: turnId, item };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class CodexJsonAdapter {
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.prompt = options.prompt;
|
|
44
|
+
this.operationId = options.operationId;
|
|
45
|
+
this.turnId = `codex-${this.operationId}`;
|
|
46
|
+
this.sessionId = '';
|
|
47
|
+
this.started = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
adapt(raw) {
|
|
51
|
+
if (!raw || typeof raw !== 'object') return [];
|
|
52
|
+
if (raw.type === 'thread.started') {
|
|
53
|
+
this.sessionId = typeof raw.thread_id === 'string' ? raw.thread_id : this.sessionId;
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
if (raw.type === 'turn.started') {
|
|
57
|
+
if (this.started) return [];
|
|
58
|
+
this.started = true;
|
|
59
|
+
return [
|
|
60
|
+
{ type: 'turn.started', turn_id: this.turnId },
|
|
61
|
+
...this.userMessageEvents(),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
if (raw.type === 'item.started' || raw.type === 'item.completed') {
|
|
65
|
+
this.ensureStarted();
|
|
66
|
+
return [itemEvent(raw.type, this.turnId, raw.item)];
|
|
67
|
+
}
|
|
68
|
+
if (raw.type === 'turn.completed') {
|
|
69
|
+
this.ensureStarted();
|
|
70
|
+
return [{ ...raw, turn_id: this.turnId }];
|
|
71
|
+
}
|
|
72
|
+
if (raw.type === 'turn.failed' || raw.type === 'error') {
|
|
73
|
+
this.ensureStarted();
|
|
74
|
+
const message = raw.message || raw.error?.message || raw.error || 'Codex execution failed';
|
|
75
|
+
return [
|
|
76
|
+
itemEvent('item.completed', this.turnId, {
|
|
77
|
+
id: `${this.turnId}-error`,
|
|
78
|
+
type: 'error',
|
|
79
|
+
message: typeof message === 'string' ? message : JSON.stringify(message),
|
|
80
|
+
status: 'failed',
|
|
81
|
+
}),
|
|
82
|
+
{ type: 'turn.completed', turn_id: this.turnId },
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
flush() {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ensureStarted() {
|
|
93
|
+
this.started = true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
userMessageEvents() {
|
|
97
|
+
if (!this.prompt) return [];
|
|
98
|
+
return [itemEvent('item.completed', this.turnId, {
|
|
99
|
+
id: `${this.turnId}-user`,
|
|
100
|
+
type: 'user_message',
|
|
101
|
+
content: [{ type: 'text', text: this.prompt }],
|
|
102
|
+
})];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function openCodeToolItem(part) {
|
|
107
|
+
const state = part.state && typeof part.state === 'object' ? part.state : {};
|
|
108
|
+
const input = state.input && typeof state.input === 'object' ? state.input : {};
|
|
109
|
+
const id = part.callID || part.id;
|
|
110
|
+
if (part.tool === 'bash') {
|
|
111
|
+
return {
|
|
112
|
+
id,
|
|
113
|
+
type: 'command_execution',
|
|
114
|
+
command: input.command || state.title || '',
|
|
115
|
+
aggregated_output: state.output || state.metadata?.output || '',
|
|
116
|
+
exit_code: Number.isFinite(state.metadata?.exit) ? state.metadata.exit : null,
|
|
117
|
+
status: state.status,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
id,
|
|
122
|
+
type: 'mcp_tool_call',
|
|
123
|
+
server: 'opencode',
|
|
124
|
+
tool: part.tool || 'tool',
|
|
125
|
+
arguments: input,
|
|
126
|
+
result: state.output,
|
|
127
|
+
error: state.error,
|
|
128
|
+
status: state.status,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
class OpenCodeJsonAdapter {
|
|
133
|
+
constructor(options) {
|
|
134
|
+
this.prompt = options.prompt;
|
|
135
|
+
this.operationId = options.operationId;
|
|
136
|
+
this.turnId = `opencode-${this.operationId}`;
|
|
137
|
+
this.sessionId = '';
|
|
138
|
+
this.started = false;
|
|
139
|
+
this.completed = false;
|
|
140
|
+
this.text = '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
adapt(raw) {
|
|
144
|
+
if (!raw || typeof raw !== 'object') return [];
|
|
145
|
+
if (typeof raw.sessionID === 'string') this.sessionId = raw.sessionID;
|
|
146
|
+
const events = this.startEvents(raw.timestamp);
|
|
147
|
+
const part = raw.part && typeof raw.part === 'object' ? raw.part : {};
|
|
148
|
+
|
|
149
|
+
if (raw.type === 'text' && typeof part.text === 'string') {
|
|
150
|
+
this.text += part.text;
|
|
151
|
+
events.push(itemEvent('item.completed', this.turnId, {
|
|
152
|
+
id: `${this.turnId}-assistant`,
|
|
153
|
+
type: 'agent_message',
|
|
154
|
+
text: this.text,
|
|
155
|
+
}));
|
|
156
|
+
} else if (raw.type === 'tool_use' && (part.callID || part.id)) {
|
|
157
|
+
const state = part.state && typeof part.state === 'object' ? part.state : {};
|
|
158
|
+
const eventType = state.status === 'completed' || state.status === 'error'
|
|
159
|
+
? 'item.completed'
|
|
160
|
+
: 'item.started';
|
|
161
|
+
events.push(itemEvent(eventType, this.turnId, openCodeToolItem(part)));
|
|
162
|
+
} else if (raw.type === 'error') {
|
|
163
|
+
const message = raw.error?.message || raw.message || raw.error || 'OpenCode execution failed';
|
|
164
|
+
events.push(itemEvent('item.completed', this.turnId, {
|
|
165
|
+
id: `${this.turnId}-error`,
|
|
166
|
+
type: 'error',
|
|
167
|
+
message: typeof message === 'string' ? message : JSON.stringify(message),
|
|
168
|
+
status: 'failed',
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (raw.type === 'step_finish' && part.reason !== 'tool-calls') {
|
|
173
|
+
events.push(...this.completeEvents(raw.timestamp));
|
|
174
|
+
}
|
|
175
|
+
return events;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
flush() {
|
|
179
|
+
return this.completeEvents();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
startEvents(timestamp) {
|
|
183
|
+
if (this.started) return [];
|
|
184
|
+
this.started = true;
|
|
185
|
+
const events = [{
|
|
186
|
+
type: 'turn.started',
|
|
187
|
+
turn_id: this.turnId,
|
|
188
|
+
...(Number.isFinite(timestamp) ? { startedAtMs: timestamp } : {}),
|
|
189
|
+
}];
|
|
190
|
+
if (this.prompt) {
|
|
191
|
+
events.push(itemEvent('item.completed', this.turnId, {
|
|
192
|
+
id: `${this.turnId}-user`,
|
|
193
|
+
type: 'user_message',
|
|
194
|
+
content: [{ type: 'text', text: this.prompt }],
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
return events;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
completeEvents(timestamp) {
|
|
201
|
+
if (!this.started || this.completed) return [];
|
|
202
|
+
this.completed = true;
|
|
203
|
+
return [{
|
|
204
|
+
type: 'turn.completed',
|
|
205
|
+
turn_id: this.turnId,
|
|
206
|
+
...(Number.isFinite(timestamp) ? { completedAt: timestamp } : {}),
|
|
207
|
+
}];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function createAdapter(provider, options) {
|
|
212
|
+
if (provider === 'codex') return new CodexJsonAdapter(options);
|
|
213
|
+
if (provider === 'opencode') return new OpenCodeJsonAdapter(options);
|
|
214
|
+
throw new Error(`Unsupported agent JSON provider: ${provider}`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
class AgentJsonStreamParser {
|
|
218
|
+
constructor(options = {}) {
|
|
219
|
+
const provider = String(options.provider || '').trim().toLowerCase();
|
|
220
|
+
const operationId = String(options.operationId || Date.now());
|
|
221
|
+
this.provider = provider;
|
|
222
|
+
this.decoder = new JsonlStreamDecoder();
|
|
223
|
+
this.adapter = createAdapter(provider, {
|
|
224
|
+
operationId,
|
|
225
|
+
prompt: typeof options.prompt === 'string' ? options.prompt.trim() : '',
|
|
226
|
+
});
|
|
227
|
+
this.events = [];
|
|
228
|
+
this.maxEvents = Number.isFinite(options.maxEvents)
|
|
229
|
+
? Math.max(1, Math.floor(options.maxEvents))
|
|
230
|
+
: DEFAULT_MAX_EVENTS;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
get sessionId() {
|
|
234
|
+
return this.adapter.sessionId;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
push(chunk) {
|
|
238
|
+
return this.appendRaw(this.decoder.push(chunk));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
flush() {
|
|
242
|
+
const events = this.appendRaw(this.decoder.flush());
|
|
243
|
+
return [...events, ...this.appendEvents(this.adapter.flush())];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
transcript(options = {}) {
|
|
247
|
+
return buildTranscriptFromEvents(this.events, options);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
appendRaw(rawEvents) {
|
|
251
|
+
const normalized = rawEvents.flatMap(event => this.adapter.adapt(event));
|
|
252
|
+
return this.appendEvents(normalized);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
appendEvents(events) {
|
|
256
|
+
if (!events.length) return [];
|
|
257
|
+
this.events.push(...events);
|
|
258
|
+
if (this.events.length > this.maxEvents) {
|
|
259
|
+
this.events.splice(0, this.events.length - this.maxEvents);
|
|
260
|
+
}
|
|
261
|
+
return events;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
module.exports = {
|
|
266
|
+
AgentJsonStreamParser,
|
|
267
|
+
JsonlStreamDecoder,
|
|
268
|
+
};
|