@linghun/tui 0.1.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 +190 -0
- package/dist/agent-completion-finalizer.d.ts +31 -0
- package/dist/agent-completion-finalizer.d.ts.map +1 -0
- package/dist/agent-completion-finalizer.js +20 -0
- package/dist/agent-handoff-safety.d.ts +13 -0
- package/dist/agent-handoff-safety.d.ts.map +1 -0
- package/dist/agent-handoff-safety.js +43 -0
- package/dist/agent-workflow-registry.d.ts +45 -0
- package/dist/agent-workflow-registry.d.ts.map +1 -0
- package/dist/agent-workflow-registry.js +12 -0
- package/dist/architecture-boundary.d.ts +151 -0
- package/dist/architecture-boundary.d.ts.map +1 -0
- package/dist/architecture-boundary.js +24 -0
- package/dist/architecture-runtime.d.ts +56 -0
- package/dist/architecture-runtime.d.ts.map +1 -0
- package/dist/architecture-runtime.js +18 -0
- package/dist/background-control-runtime.d.ts +29 -0
- package/dist/background-control-runtime.d.ts.map +1 -0
- package/dist/background-control-runtime.js +148 -0
- package/dist/bash-subcommand-parser.d.ts +34 -0
- package/dist/bash-subcommand-parser.d.ts.map +1 -0
- package/dist/bash-subcommand-parser.js +8 -0
- package/dist/batch-tool-confirmation.d.ts +18 -0
- package/dist/batch-tool-confirmation.d.ts.map +1 -0
- package/dist/batch-tool-confirmation.js +100 -0
- package/dist/break-cache-runtime.d.ts +40 -0
- package/dist/break-cache-runtime.d.ts.map +1 -0
- package/dist/break-cache-runtime.js +17 -0
- package/dist/btw-runtime.d.ts +45 -0
- package/dist/btw-runtime.d.ts.map +1 -0
- package/dist/btw-runtime.js +14 -0
- package/dist/cache-command-runtime.d.ts +22 -0
- package/dist/cache-command-runtime.d.ts.map +1 -0
- package/dist/cache-command-runtime.js +33 -0
- package/dist/cache-freshness.d.ts +26 -0
- package/dist/cache-freshness.d.ts.map +1 -0
- package/dist/cache-freshness.js +14 -0
- package/dist/capability-runtime.d.ts +75 -0
- package/dist/capability-runtime.d.ts.map +1 -0
- package/dist/capability-runtime.js +97 -0
- package/dist/chunk-2FVEKTKN.js +86 -0
- package/dist/chunk-2YL5VKJ5.js +531 -0
- package/dist/chunk-3AKXDMVS.js +85 -0
- package/dist/chunk-3GCIXKCI.js +221 -0
- package/dist/chunk-3LT6OWQ2.js +258 -0
- package/dist/chunk-3XNUDLOM.js +91 -0
- package/dist/chunk-4EIC5BCT.js +475 -0
- package/dist/chunk-4EP3TUFF.js +238 -0
- package/dist/chunk-4I2NWBOM.js +117 -0
- package/dist/chunk-4K6UB524.js +443 -0
- package/dist/chunk-4T5DJW54.js +88 -0
- package/dist/chunk-4WHZ6JKD.js +8105 -0
- package/dist/chunk-5H7RRF7C.js +6 -0
- package/dist/chunk-64MJP6FK.js +558 -0
- package/dist/chunk-66BNE332.js +1617 -0
- package/dist/chunk-6CI6TKLN.js +50 -0
- package/dist/chunk-6RJVTUWI.js +16 -0
- package/dist/chunk-6SMM5CMP.js +100 -0
- package/dist/chunk-6USL33ZO.js +289 -0
- package/dist/chunk-7ZE5JFAZ.js +760 -0
- package/dist/chunk-AKPXMCVF.js +1373 -0
- package/dist/chunk-AO4CXI37.js +284 -0
- package/dist/chunk-APJIC2O5.js +150 -0
- package/dist/chunk-B4GQTZMT.js +607 -0
- package/dist/chunk-BFVPLGAC.js +93 -0
- package/dist/chunk-BOV4K7FP.js +588 -0
- package/dist/chunk-CFMSB6ST.js +59 -0
- package/dist/chunk-CFXB5SE5.js +502 -0
- package/dist/chunk-CRQORMFF.js +32 -0
- package/dist/chunk-CRSLDQOA.js +146 -0
- package/dist/chunk-CRW3636S.js +214 -0
- package/dist/chunk-D3UTL2QX.js +86 -0
- package/dist/chunk-D7TCSOAZ.js +331 -0
- package/dist/chunk-DDXS2RDZ.js +228 -0
- package/dist/chunk-DICVLZHH.js +144 -0
- package/dist/chunk-DNQN74CC.js +1186 -0
- package/dist/chunk-DTK5NBTV.js +912 -0
- package/dist/chunk-E72U7WW7.js +50 -0
- package/dist/chunk-EBACIBJP.js +356 -0
- package/dist/chunk-ECFLCY5V.js +530 -0
- package/dist/chunk-EORRZP3F.js +109 -0
- package/dist/chunk-F43AMWLZ.js +115 -0
- package/dist/chunk-F46N43MG.js +56 -0
- package/dist/chunk-F6TVBCZV.js +51 -0
- package/dist/chunk-FRIMDSRU.js +242 -0
- package/dist/chunk-FTAEPAVY.js +314 -0
- package/dist/chunk-GC55DMZV.js +156 -0
- package/dist/chunk-GCMH5P4W.js +422 -0
- package/dist/chunk-GDQQNPBP.js +251 -0
- package/dist/chunk-GKZYTPN2.js +279 -0
- package/dist/chunk-GLWTWEGX.js +272 -0
- package/dist/chunk-GMUCSNUD.js +586 -0
- package/dist/chunk-GTP2KPLY.js +167 -0
- package/dist/chunk-GW5YDCRZ.js +42 -0
- package/dist/chunk-H3T4EF5F.js +87 -0
- package/dist/chunk-HAEU6OTS.js +381 -0
- package/dist/chunk-HQIJGQYU.js +172 -0
- package/dist/chunk-HW2TBXVK.js +34 -0
- package/dist/chunk-HWD22O6F.js +94 -0
- package/dist/chunk-I3NTAIMF.js +280 -0
- package/dist/chunk-IN42UISW.js +372 -0
- package/dist/chunk-IWUIOLMF.js +82 -0
- package/dist/chunk-J7ZE2JKP.js +283 -0
- package/dist/chunk-JBLVBO3U.js +109 -0
- package/dist/chunk-JDWXC2OQ.js +800 -0
- package/dist/chunk-JGDIO2NF.js +74 -0
- package/dist/chunk-JHGWGH2C.js +182 -0
- package/dist/chunk-JLCPHVBN.js +42 -0
- package/dist/chunk-JO5ANTMR.js +6027 -0
- package/dist/chunk-JPXSFZFC.js +100 -0
- package/dist/chunk-JQCRCDOC.js +1195 -0
- package/dist/chunk-K4FSYBSY.js +41 -0
- package/dist/chunk-K56D3X7S.js +1225 -0
- package/dist/chunk-KI7C6ZOD.js +92 -0
- package/dist/chunk-KO64OFSG.js +58 -0
- package/dist/chunk-KQJHVJZB.js +227 -0
- package/dist/chunk-KTWV5JC5.js +59 -0
- package/dist/chunk-L4XXW6Y5.js +374 -0
- package/dist/chunk-L5GOCMZP.js +18 -0
- package/dist/chunk-LDABZV5V.js +278 -0
- package/dist/chunk-LHHKPGLX.js +903 -0
- package/dist/chunk-LL7LBRDL.js +60 -0
- package/dist/chunk-LQTVYUT3.js +421 -0
- package/dist/chunk-LVIM2PA7.js +663 -0
- package/dist/chunk-M4AIK2SP.js +215 -0
- package/dist/chunk-MLUIOBKL.js +420 -0
- package/dist/chunk-MOJL4X4L.js +47 -0
- package/dist/chunk-MVONSJEN.js +300 -0
- package/dist/chunk-N7G2X2LK.js +709 -0
- package/dist/chunk-NKFKOEYX.js +146 -0
- package/dist/chunk-NMNOAFFT.js +167 -0
- package/dist/chunk-NSIKYD3X.js +74 -0
- package/dist/chunk-O7EFPSMC.js +60 -0
- package/dist/chunk-O7S3HYE6.js +210 -0
- package/dist/chunk-OEYW3JE3.js +262 -0
- package/dist/chunk-OF3K3CU5.js +159 -0
- package/dist/chunk-OMZYPQVA.js +298 -0
- package/dist/chunk-OZMX3E35.js +248 -0
- package/dist/chunk-P277M7Z5.js +303 -0
- package/dist/chunk-P4CPRJLI.js +65 -0
- package/dist/chunk-PBIPV4LD.js +494 -0
- package/dist/chunk-PGNALDEH.js +2003 -0
- package/dist/chunk-PGWW3DVE.js +157 -0
- package/dist/chunk-QB4VWH7W.js +515 -0
- package/dist/chunk-QBCGAIU7.js +120 -0
- package/dist/chunk-QIU3FJPC.js +99 -0
- package/dist/chunk-QLRTQHTR.js +744 -0
- package/dist/chunk-QTDGRZMZ.js +171 -0
- package/dist/chunk-RBOQJFIZ.js +183 -0
- package/dist/chunk-RDGM4RUE.js +178 -0
- package/dist/chunk-RM5JDRCW.js +71 -0
- package/dist/chunk-RM5QMOFY.js +189 -0
- package/dist/chunk-RMLTVKOY.js +588 -0
- package/dist/chunk-RVY34HK4.js +79 -0
- package/dist/chunk-S3YWTBXL.js +43 -0
- package/dist/chunk-SJOS5PM6.js +64 -0
- package/dist/chunk-SOPYWTFV.js +90 -0
- package/dist/chunk-SQIBPLLV.js +15 -0
- package/dist/chunk-SRZIA6B4.js +136 -0
- package/dist/chunk-SYBNJZEL.js +250 -0
- package/dist/chunk-TFZEFIQT.js +17 -0
- package/dist/chunk-THZBFYAH.js +136 -0
- package/dist/chunk-TJLC3QAS.js +83 -0
- package/dist/chunk-TYF4GJR3.js +598 -0
- package/dist/chunk-UDQT5CWK.js +252 -0
- package/dist/chunk-UOHZQIVL.js +168 -0
- package/dist/chunk-URNQUECO.js +187 -0
- package/dist/chunk-UT2TYK2A.js +148 -0
- package/dist/chunk-UT5BOJKU.js +190 -0
- package/dist/chunk-V7GDHHBL.js +526 -0
- package/dist/chunk-VCSRBS47.js +133 -0
- package/dist/chunk-VIBENDE3.js +152 -0
- package/dist/chunk-VTQL23UM.js +302 -0
- package/dist/chunk-W3KHJNSH.js +281 -0
- package/dist/chunk-W6NU7ZAV.js +52 -0
- package/dist/chunk-WHFDDZHY.js +407 -0
- package/dist/chunk-WJWYRBWH.js +48 -0
- package/dist/chunk-WKMBK5UP.js +145 -0
- package/dist/chunk-WQMSRO4D.js +489 -0
- package/dist/chunk-WV6YJGZR.js +81 -0
- package/dist/chunk-WVAQYKGL.js +269 -0
- package/dist/chunk-X7A22JHP.js +106 -0
- package/dist/chunk-XFPNU42I.js +59 -0
- package/dist/chunk-YH6UIHNF.js +161 -0
- package/dist/chunk-YPQFSFYK.js +19 -0
- package/dist/chunk-YTQFOZRZ.js +110 -0
- package/dist/chunk-ZJK25VFP.js +506 -0
- package/dist/chunk-ZOSK2UEU.js +1555 -0
- package/dist/chunk-ZYSN7AWW.js +336 -0
- package/dist/chunk-ZZ2CNCXJ.js +282 -0
- package/dist/command-panel-runtime.d.ts +33 -0
- package/dist/command-panel-runtime.d.ts.map +1 -0
- package/dist/command-panel-runtime.js +80 -0
- package/dist/compact-cache-command-runtime.d.ts +38 -0
- package/dist/compact-cache-command-runtime.d.ts.map +1 -0
- package/dist/compact-cache-command-runtime.js +146 -0
- package/dist/compact-context.d.ts +35 -0
- package/dist/compact-context.d.ts.map +1 -0
- package/dist/compact-context.js +16 -0
- package/dist/compact-preflight-runtime.d.ts +46 -0
- package/dist/compact-preflight-runtime.d.ts.map +1 -0
- package/dist/compact-preflight-runtime.js +62 -0
- package/dist/connector-runtime.d.ts +72 -0
- package/dist/connector-runtime.d.ts.map +1 -0
- package/dist/connector-runtime.js +88 -0
- package/dist/context-estimator.d.ts +20 -0
- package/dist/context-estimator.d.ts.map +1 -0
- package/dist/context-estimator.js +18 -0
- package/dist/context-window-runtime.d.ts +12 -0
- package/dist/context-window-runtime.d.ts.map +1 -0
- package/dist/context-window-runtime.js +10 -0
- package/dist/deep-compact-runtime.d.ts +53 -0
- package/dist/deep-compact-runtime.d.ts.map +1 -0
- package/dist/deep-compact-runtime.js +35 -0
- package/dist/deferred-tools-catalog.d.ts +52 -0
- package/dist/deferred-tools-catalog.d.ts.map +1 -0
- package/dist/deferred-tools-catalog.js +42 -0
- package/dist/details-status-runtime.d.ts +48 -0
- package/dist/details-status-runtime.d.ts.map +1 -0
- package/dist/details-status-runtime.js +102 -0
- package/dist/evidence-runtime.d.ts +48 -0
- package/dist/evidence-runtime.d.ts.map +1 -0
- package/dist/evidence-runtime.js +92 -0
- package/dist/extension-command-runtime.d.ts +63 -0
- package/dist/extension-command-runtime.d.ts.map +1 -0
- package/dist/extension-command-runtime.js +67 -0
- package/dist/extension-slash-runtime.d.ts +11 -0
- package/dist/extension-slash-runtime.d.ts.map +1 -0
- package/dist/extension-slash-runtime.js +79 -0
- package/dist/external-editor-runtime.d.ts +32 -0
- package/dist/external-editor-runtime.d.ts.map +1 -0
- package/dist/external-editor-runtime.js +71 -0
- package/dist/failure-learning-command-runtime.d.ts +10 -0
- package/dist/failure-learning-command-runtime.d.ts.map +1 -0
- package/dist/failure-learning-command-runtime.js +78 -0
- package/dist/failure-learning-presenter.d.ts +6 -0
- package/dist/failure-learning-presenter.d.ts.map +1 -0
- package/dist/failure-learning-presenter.js +12 -0
- package/dist/failure-learning-runtime.d.ts +39 -0
- package/dist/failure-learning-runtime.d.ts.map +1 -0
- package/dist/failure-learning-runtime.js +39 -0
- package/dist/feature-flag-runtime.d.ts +8 -0
- package/dist/feature-flag-runtime.d.ts.map +1 -0
- package/dist/feature-flag-runtime.js +12 -0
- package/dist/feishu-long-connection-runtime.d.ts +12 -0
- package/dist/feishu-long-connection-runtime.d.ts.map +1 -0
- package/dist/feishu-long-connection-runtime.js +7 -0
- package/dist/final-answer-gate.d.ts +24 -0
- package/dist/final-answer-gate.d.ts.map +1 -0
- package/dist/final-answer-gate.js +26 -0
- package/dist/ghost-text.d.ts +16 -0
- package/dist/ghost-text.d.ts.map +1 -0
- package/dist/ghost-text.js +8 -0
- package/dist/git-branch-runtime.d.ts +14 -0
- package/dist/git-branch-runtime.d.ts.map +1 -0
- package/dist/git-branch-runtime.js +68 -0
- package/dist/git-command-runtime.d.ts +22 -0
- package/dist/git-command-runtime.d.ts.map +1 -0
- package/dist/git-command-runtime.js +89 -0
- package/dist/git-operation-runtime.d.ts +188 -0
- package/dist/git-operation-runtime.d.ts.map +1 -0
- package/dist/git-operation-runtime.js +45 -0
- package/dist/git-runtime.d.ts +113 -0
- package/dist/git-runtime.d.ts.map +1 -0
- package/dist/git-runtime.js +16 -0
- package/dist/git-slash-runtime.d.ts +38 -0
- package/dist/git-slash-runtime.d.ts.map +1 -0
- package/dist/git-slash-runtime.js +18 -0
- package/dist/git-tool-dispatch-runtime.d.ts +108 -0
- package/dist/git-tool-dispatch-runtime.d.ts.map +1 -0
- package/dist/git-tool-dispatch-runtime.js +25 -0
- package/dist/git-tool-runtime.d.ts +64 -0
- package/dist/git-tool-runtime.d.ts.map +1 -0
- package/dist/git-tool-runtime.js +36 -0
- package/dist/guard-wiring.d.ts +67 -0
- package/dist/guard-wiring.d.ts.map +1 -0
- package/dist/guard-wiring.js +21 -0
- package/dist/handoff-session-runtime.d.ts +11 -0
- package/dist/handoff-session-runtime.d.ts.map +1 -0
- package/dist/handoff-session-runtime.js +36 -0
- package/dist/index-result-presenter.d.ts +14 -0
- package/dist/index-result-presenter.d.ts.map +1 -0
- package/dist/index-result-presenter.js +28 -0
- package/dist/index-runtime.d.ts +64 -0
- package/dist/index-runtime.d.ts.map +1 -0
- package/dist/index-runtime.js +28 -0
- package/dist/index-tool-runtime.d.ts +44 -0
- package/dist/index-tool-runtime.d.ts.map +1 -0
- package/dist/index-tool-runtime.js +24 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2346 -0
- package/dist/job-agent-command-runtime.d.ts +127 -0
- package/dist/job-agent-command-runtime.d.ts.map +1 -0
- package/dist/job-agent-command-runtime.js +138 -0
- package/dist/job-runner-presenter.d.ts +32 -0
- package/dist/job-runner-presenter.d.ts.map +1 -0
- package/dist/job-runner-presenter.js +30 -0
- package/dist/job-runtime.d.ts +65 -0
- package/dist/job-runtime.d.ts.map +1 -0
- package/dist/job-runtime.js +88 -0
- package/dist/keybinding-runtime.d.ts +29 -0
- package/dist/keybinding-runtime.d.ts.map +1 -0
- package/dist/keybinding-runtime.js +14 -0
- package/dist/log-artifact.d.ts +55 -0
- package/dist/log-artifact.d.ts.map +1 -0
- package/dist/log-artifact.js +10 -0
- package/dist/mcp-index-command-runtime.d.ts +21 -0
- package/dist/mcp-index-command-runtime.d.ts.map +1 -0
- package/dist/mcp-index-command-runtime.js +18 -0
- package/dist/mcp-index-runtime.d.ts +106 -0
- package/dist/mcp-index-runtime.d.ts.map +1 -0
- package/dist/mcp-index-runtime.js +142 -0
- package/dist/mcp-sse-runtime.d.ts +13 -0
- package/dist/mcp-sse-runtime.d.ts.map +1 -0
- package/dist/mcp-sse-runtime.js +8 -0
- package/dist/mcp-stdio-runtime.d.ts +37 -0
- package/dist/mcp-stdio-runtime.d.ts.map +1 -0
- package/dist/mcp-stdio-runtime.js +15 -0
- package/dist/memory-command-runtime.d.ts +37 -0
- package/dist/memory-command-runtime.d.ts.map +1 -0
- package/dist/memory-command-runtime.js +88 -0
- package/dist/memory-eviction-runtime.d.ts +7 -0
- package/dist/memory-eviction-runtime.d.ts.map +1 -0
- package/dist/memory-eviction-runtime.js +12 -0
- package/dist/memory-extraction-runtime.d.ts +40 -0
- package/dist/memory-extraction-runtime.d.ts.map +1 -0
- package/dist/memory-extraction-runtime.js +20 -0
- package/dist/memory-rules-runtime.d.ts +15 -0
- package/dist/memory-rules-runtime.d.ts.map +1 -0
- package/dist/memory-rules-runtime.js +14 -0
- package/dist/meta-scheduler-complexity.d.ts +16 -0
- package/dist/meta-scheduler-complexity.d.ts.map +1 -0
- package/dist/meta-scheduler-complexity.js +37 -0
- package/dist/meta-scheduler-runtime.d.ts +288 -0
- package/dist/meta-scheduler-runtime.d.ts.map +1 -0
- package/dist/meta-scheduler-runtime.js +17 -0
- package/dist/model-command-runtime.d.ts +12 -0
- package/dist/model-command-runtime.d.ts.map +1 -0
- package/dist/model-command-runtime.js +84 -0
- package/dist/model-doctor-runtime.d.ts +81 -0
- package/dist/model-doctor-runtime.d.ts.map +1 -0
- package/dist/model-doctor-runtime.js +46 -0
- package/dist/model-loop-runtime.d.ts +189 -0
- package/dist/model-loop-runtime.d.ts.map +1 -0
- package/dist/model-loop-runtime.js +141 -0
- package/dist/model-prompt-runtime.d.ts +25 -0
- package/dist/model-prompt-runtime.d.ts.map +1 -0
- package/dist/model-prompt-runtime.js +33 -0
- package/dist/model-setup-runtime.d.ts +28 -0
- package/dist/model-setup-runtime.d.ts.map +1 -0
- package/dist/model-setup-runtime.js +26 -0
- package/dist/model-stream-runtime.d.ts +47 -0
- package/dist/model-stream-runtime.d.ts.map +1 -0
- package/dist/model-stream-runtime.js +136 -0
- package/dist/model-tool-runtime.d.ts +114 -0
- package/dist/model-tool-runtime.d.ts.map +1 -0
- package/dist/model-tool-runtime.js +144 -0
- package/dist/natural-command-bridge.d.ts +158 -0
- package/dist/natural-command-bridge.d.ts.map +1 -0
- package/dist/natural-command-bridge.js +36 -0
- package/dist/pending-details-presenter.d.ts +8 -0
- package/dist/pending-details-presenter.d.ts.map +1 -0
- package/dist/pending-details-presenter.js +12 -0
- package/dist/permission-approval-runtime.d.ts +28 -0
- package/dist/permission-approval-runtime.d.ts.map +1 -0
- package/dist/permission-approval-runtime.js +136 -0
- package/dist/permission-continuation-runtime.d.ts +90 -0
- package/dist/permission-continuation-runtime.d.ts.map +1 -0
- package/dist/permission-continuation-runtime.js +68 -0
- package/dist/permission-policy-engine.d.ts +51 -0
- package/dist/permission-policy-engine.d.ts.map +1 -0
- package/dist/permission-policy-engine.js +12 -0
- package/dist/permission-presenter.d.ts +13 -0
- package/dist/permission-presenter.d.ts.map +1 -0
- package/dist/permission-presenter.js +8 -0
- package/dist/persistent-history.d.ts +18 -0
- package/dist/persistent-history.d.ts.map +1 -0
- package/dist/persistent-history.js +126 -0
- package/dist/platform-security.d.ts +4 -0
- package/dist/platform-security.d.ts.map +1 -0
- package/dist/platform-security.js +10 -0
- package/dist/process-command-runtime.d.ts +9 -0
- package/dist/process-command-runtime.d.ts.map +1 -0
- package/dist/process-command-runtime.js +11 -0
- package/dist/process-guard.d.ts +56 -0
- package/dist/process-guard.d.ts.map +1 -0
- package/dist/process-guard.js +22 -0
- package/dist/prompt-command-runtime.d.ts +12 -0
- package/dist/prompt-command-runtime.d.ts.map +1 -0
- package/dist/prompt-command-runtime.js +10 -0
- package/dist/prompt-stash.d.ts +15 -0
- package/dist/prompt-stash.d.ts.map +1 -0
- package/dist/prompt-stash.js +8 -0
- package/dist/provider-circuit-breaker.d.ts +132 -0
- package/dist/provider-circuit-breaker.d.ts.map +1 -0
- package/dist/provider-circuit-breaker.js +31 -0
- package/dist/provider-loop-runtime.d.ts +18 -0
- package/dist/provider-loop-runtime.d.ts.map +1 -0
- package/dist/provider-loop-runtime.js +16 -0
- package/dist/remote-command-runtime.d.ts +47 -0
- package/dist/remote-command-runtime.d.ts.map +1 -0
- package/dist/remote-command-runtime.js +125 -0
- package/dist/remote-inbound-bridge-runtime.d.ts +152 -0
- package/dist/remote-inbound-bridge-runtime.d.ts.map +1 -0
- package/dist/remote-inbound-bridge-runtime.js +44 -0
- package/dist/remote-mcp-presenter.d.ts +5 -0
- package/dist/remote-mcp-presenter.d.ts.map +1 -0
- package/dist/remote-mcp-presenter.js +10 -0
- package/dist/remote-repl-bridge-runtime.d.ts +134 -0
- package/dist/remote-repl-bridge-runtime.d.ts.map +1 -0
- package/dist/remote-repl-bridge-runtime.js +20 -0
- package/dist/remote-transport.d.ts +50 -0
- package/dist/remote-transport.d.ts.map +1 -0
- package/dist/remote-transport.js +14 -0
- package/dist/request-lifecycle-presenter.d.ts +25 -0
- package/dist/request-lifecycle-presenter.d.ts.map +1 -0
- package/dist/request-lifecycle-presenter.js +22 -0
- package/dist/runner-runtime.d.ts +41 -0
- package/dist/runner-runtime.d.ts.map +1 -0
- package/dist/runner-runtime.js +35 -0
- package/dist/runtime-budget.d.ts +38 -0
- package/dist/runtime-budget.d.ts.map +1 -0
- package/dist/runtime-budget.js +78 -0
- package/dist/runtime-path-marker.d.ts +112 -0
- package/dist/runtime-path-marker.d.ts.map +1 -0
- package/dist/runtime-path-marker.js +18 -0
- package/dist/runtime-status-presenter.d.ts +22 -0
- package/dist/runtime-status-presenter.d.ts.map +1 -0
- package/dist/runtime-status-presenter.js +15 -0
- package/dist/runtime-status-snapshot.d.ts +52 -0
- package/dist/runtime-status-snapshot.d.ts.map +1 -0
- package/dist/runtime-status-snapshot.js +11 -0
- package/dist/runtime-utils.d.ts +2 -0
- package/dist/runtime-utils.d.ts.map +1 -0
- package/dist/runtime-utils.js +6 -0
- package/dist/shell/clipboard.d.ts +23 -0
- package/dist/shell/clipboard.d.ts.map +1 -0
- package/dist/shell/clipboard.js +8 -0
- package/dist/shell/components/AgentProgressTree.d.ts +9 -0
- package/dist/shell/components/AgentProgressTree.d.ts.map +1 -0
- package/dist/shell/components/AgentProgressTree.js +9 -0
- package/dist/shell/components/BackgroundTaskOverlay.d.ts +8 -0
- package/dist/shell/components/BackgroundTaskOverlay.d.ts.map +1 -0
- package/dist/shell/components/BackgroundTaskOverlay.js +8 -0
- package/dist/shell/components/BtwPanel.d.ts +16 -0
- package/dist/shell/components/BtwPanel.d.ts.map +1 -0
- package/dist/shell/components/BtwPanel.js +8 -0
- package/dist/shell/components/CommandPanel.d.ts +11 -0
- package/dist/shell/components/CommandPanel.d.ts.map +1 -0
- package/dist/shell/components/CommandPanel.js +8 -0
- package/dist/shell/components/Composer.d.ts +187 -0
- package/dist/shell/components/Composer.d.ts.map +1 -0
- package/dist/shell/components/Composer.js +99 -0
- package/dist/shell/components/ConfigPanel.d.ts +11 -0
- package/dist/shell/components/ConfigPanel.d.ts.map +1 -0
- package/dist/shell/components/ConfigPanel.js +8 -0
- package/dist/shell/components/CtrlOToExpand.d.ts +30 -0
- package/dist/shell/components/CtrlOToExpand.d.ts.map +1 -0
- package/dist/shell/components/CtrlOToExpand.js +16 -0
- package/dist/shell/components/HelpPanel.d.ts +19 -0
- package/dist/shell/components/HelpPanel.d.ts.map +1 -0
- package/dist/shell/components/HelpPanel.js +8 -0
- package/dist/shell/components/HistorySearchPanel.d.ts +14 -0
- package/dist/shell/components/HistorySearchPanel.d.ts.map +1 -0
- package/dist/shell/components/HistorySearchPanel.js +104 -0
- package/dist/shell/components/MessageMarkdown.d.ts +34 -0
- package/dist/shell/components/MessageMarkdown.d.ts.map +1 -0
- package/dist/shell/components/MessageMarkdown.js +18 -0
- package/dist/shell/components/MessageResponse.d.ts +14 -0
- package/dist/shell/components/MessageResponse.d.ts.map +1 -0
- package/dist/shell/components/MessageResponse.js +6 -0
- package/dist/shell/components/MouseInputRouter.d.ts +28 -0
- package/dist/shell/components/MouseInputRouter.d.ts.map +1 -0
- package/dist/shell/components/MouseInputRouter.js +84 -0
- package/dist/shell/components/NotificationStack.d.ts +19 -0
- package/dist/shell/components/NotificationStack.d.ts.map +1 -0
- package/dist/shell/components/NotificationStack.js +6 -0
- package/dist/shell/components/OutputLine.d.ts +19 -0
- package/dist/shell/components/OutputLine.d.ts.map +1 -0
- package/dist/shell/components/OutputLine.js +38 -0
- package/dist/shell/components/ProductBlock.d.ts +10 -0
- package/dist/shell/components/ProductBlock.d.ts.map +1 -0
- package/dist/shell/components/ProductBlock.js +12 -0
- package/dist/shell/components/ScrollViewport.d.ts +43 -0
- package/dist/shell/components/ScrollViewport.d.ts.map +1 -0
- package/dist/shell/components/ScrollViewport.js +86 -0
- package/dist/shell/components/SessionsPanel.d.ts +24 -0
- package/dist/shell/components/SessionsPanel.d.ts.map +1 -0
- package/dist/shell/components/SessionsPanel.js +8 -0
- package/dist/shell/components/ShellApp.d.ts +8 -0
- package/dist/shell/components/ShellApp.d.ts.map +1 -0
- package/dist/shell/components/ShellApp.js +45 -0
- package/dist/shell/components/ShortcutPanel.d.ts +14 -0
- package/dist/shell/components/ShortcutPanel.d.ts.map +1 -0
- package/dist/shell/components/ShortcutPanel.js +59 -0
- package/dist/shell/components/SlashSuggestions.d.ts +24 -0
- package/dist/shell/components/SlashSuggestions.d.ts.map +1 -0
- package/dist/shell/components/SlashSuggestions.js +7 -0
- package/dist/shell/components/StatusFooter.d.ts +30 -0
- package/dist/shell/components/StatusFooter.d.ts.map +1 -0
- package/dist/shell/components/StatusFooter.js +7 -0
- package/dist/shell/components/StatusTray.d.ts +9 -0
- package/dist/shell/components/StatusTray.d.ts.map +1 -0
- package/dist/shell/components/StatusTray.js +6 -0
- package/dist/shell/components/StructuredDiff.d.ts +9 -0
- package/dist/shell/components/StructuredDiff.d.ts.map +1 -0
- package/dist/shell/components/StructuredDiff.js +7 -0
- package/dist/shell/components/TaskListView.d.ts +9 -0
- package/dist/shell/components/TaskListView.d.ts.map +1 -0
- package/dist/shell/components/TaskListView.js +9 -0
- package/dist/shell/components/TaskSuggestionBar.d.ts +15 -0
- package/dist/shell/components/TaskSuggestionBar.d.ts.map +1 -0
- package/dist/shell/components/TaskSuggestionBar.js +8 -0
- package/dist/shell/components/UnseenMessagePill.d.ts +12 -0
- package/dist/shell/components/UnseenMessagePill.d.ts.map +1 -0
- package/dist/shell/components/UnseenMessagePill.js +6 -0
- package/dist/shell/components/WorkflowProgressView.d.ts +9 -0
- package/dist/shell/components/WorkflowProgressView.d.ts.map +1 -0
- package/dist/shell/components/WorkflowProgressView.js +9 -0
- package/dist/shell/components/useAnchoredCursor.d.ts +32 -0
- package/dist/shell/components/useAnchoredCursor.d.ts.map +1 -0
- package/dist/shell/components/useAnchoredCursor.js +6 -0
- package/dist/shell/hooks/useRenderThrottle.d.ts +2 -0
- package/dist/shell/hooks/useRenderThrottle.d.ts.map +1 -0
- package/dist/shell/hooks/useRenderThrottle.js +35 -0
- package/dist/shell/hooks/useScrollBatcher.d.ts +10 -0
- package/dist/shell/hooks/useScrollBatcher.d.ts.map +1 -0
- package/dist/shell/hooks/useScrollBatcher.js +23 -0
- package/dist/shell/hooks/useScrollRuntime.d.ts +2 -0
- package/dist/shell/hooks/useScrollRuntime.d.ts.map +1 -0
- package/dist/shell/hooks/useScrollRuntime.js +6 -0
- package/dist/shell/hyperlink-utils.d.ts +18 -0
- package/dist/shell/hyperlink-utils.d.ts.map +1 -0
- package/dist/shell/hyperlink-utils.js +8 -0
- package/dist/shell/ink-renderer.d.ts +18 -0
- package/dist/shell/ink-renderer.d.ts.map +1 -0
- package/dist/shell/ink-renderer.js +54 -0
- package/dist/shell/models/command-transcript-presenter.d.ts +73 -0
- package/dist/shell/models/command-transcript-presenter.d.ts.map +1 -0
- package/dist/shell/models/command-transcript-presenter.js +26 -0
- package/dist/shell/models/help-panel.d.ts +37 -0
- package/dist/shell/models/help-panel.d.ts.map +1 -0
- package/dist/shell/models/help-panel.js +10 -0
- package/dist/shell/models/permission-elevation.d.ts +65 -0
- package/dist/shell/models/permission-elevation.d.ts.map +1 -0
- package/dist/shell/models/permission-elevation.js +10 -0
- package/dist/shell/models/permission-explanation.d.ts +45 -0
- package/dist/shell/models/permission-explanation.d.ts.map +1 -0
- package/dist/shell/models/permission-explanation.js +14 -0
- package/dist/shell/models/session-panel.d.ts +22 -0
- package/dist/shell/models/session-panel.d.ts.map +1 -0
- package/dist/shell/models/session-panel.js +18 -0
- package/dist/shell/models/task-scroll-state.d.ts +24 -0
- package/dist/shell/models/task-scroll-state.d.ts.map +1 -0
- package/dist/shell/models/task-scroll-state.js +26 -0
- package/dist/shell/models/terminal-input-runtime.d.ts +37 -0
- package/dist/shell/models/terminal-input-runtime.d.ts.map +1 -0
- package/dist/shell/models/terminal-input-runtime.js +18 -0
- package/dist/shell/models/transcript-scroll-state.d.ts +57 -0
- package/dist/shell/models/transcript-scroll-state.d.ts.map +1 -0
- package/dist/shell/models/transcript-scroll-state.js +12 -0
- package/dist/shell/models/transcript-selection-state.d.ts +39 -0
- package/dist/shell/models/transcript-selection-state.d.ts.map +1 -0
- package/dist/shell/models/transcript-selection-state.js +25 -0
- package/dist/shell/models/wheel-acceleration.d.ts +52 -0
- package/dist/shell/models/wheel-acceleration.d.ts.map +1 -0
- package/dist/shell/models/wheel-acceleration.js +6 -0
- package/dist/shell/output-utils.d.ts +22 -0
- package/dist/shell/output-utils.d.ts.map +1 -0
- package/dist/shell/output-utils.js +12 -0
- package/dist/shell/plain-renderer.d.ts +12 -0
- package/dist/shell/plain-renderer.d.ts.map +1 -0
- package/dist/shell/plain-renderer.js +13 -0
- package/dist/shell/progress-views.d.ts +10 -0
- package/dist/shell/progress-views.d.ts.map +1 -0
- package/dist/shell/progress-views.js +17 -0
- package/dist/shell/stdout-flush-barrier.d.ts +39 -0
- package/dist/shell/stdout-flush-barrier.d.ts.map +1 -0
- package/dist/shell/stdout-flush-barrier.js +10 -0
- package/dist/shell/terminal-capability.d.ts +54 -0
- package/dist/shell/terminal-capability.d.ts.map +1 -0
- package/dist/shell/terminal-capability.js +10 -0
- package/dist/shell/terminal-interaction-runtime.d.ts +11 -0
- package/dist/shell/terminal-interaction-runtime.d.ts.map +1 -0
- package/dist/shell/terminal-interaction-runtime.js +38 -0
- package/dist/shell/terminal-state-recovery.d.ts +52 -0
- package/dist/shell/terminal-state-recovery.d.ts.map +1 -0
- package/dist/shell/terminal-state-recovery.js +11 -0
- package/dist/shell/text-utils.d.ts +40 -0
- package/dist/shell/text-utils.d.ts.map +1 -0
- package/dist/shell/text-utils.js +26 -0
- package/dist/shell/theme.d.ts +41 -0
- package/dist/shell/theme.d.ts.map +1 -0
- package/dist/shell/theme.js +8 -0
- package/dist/shell/types.d.ts +784 -0
- package/dist/shell/types.d.ts.map +1 -0
- package/dist/shell/types.js +0 -0
- package/dist/shell/view-model.d.ts +82 -0
- package/dist/shell/view-model.d.ts.map +1 -0
- package/dist/shell/view-model.js +48 -0
- package/dist/slash-command-runtime.d.ts +64 -0
- package/dist/slash-command-runtime.d.ts.map +1 -0
- package/dist/slash-command-runtime.js +186 -0
- package/dist/slash-dispatch.d.ts +48 -0
- package/dist/slash-dispatch.d.ts.map +1 -0
- package/dist/slash-dispatch.js +53 -0
- package/dist/startup-runtime.d.ts +48 -0
- package/dist/startup-runtime.d.ts.map +1 -0
- package/dist/startup-runtime.js +43 -0
- package/dist/terminal-readiness-presenter.d.ts +131 -0
- package/dist/terminal-readiness-presenter.d.ts.map +1 -0
- package/dist/terminal-readiness-presenter.js +16 -0
- package/dist/terminal-readiness-runtime.d.ts +5 -0
- package/dist/terminal-readiness-runtime.d.ts.map +1 -0
- package/dist/terminal-readiness-runtime.js +15 -0
- package/dist/terminal-setup-runtime.d.ts +34 -0
- package/dist/terminal-setup-runtime.d.ts.map +1 -0
- package/dist/terminal-setup-runtime.js +257 -0
- package/dist/tool-output-presenter.d.ts +38 -0
- package/dist/tool-output-presenter.d.ts.map +1 -0
- package/dist/tool-output-presenter.js +16 -0
- package/dist/tool-result-budget.d.ts +42 -0
- package/dist/tool-result-budget.d.ts.map +1 -0
- package/dist/tool-result-budget.js +11 -0
- package/dist/tui-agent-job-runtime.d.ts +38 -0
- package/dist/tui-agent-job-runtime.d.ts.map +1 -0
- package/dist/tui-agent-job-runtime.js +86 -0
- package/dist/tui-context-runtime.d.ts +426 -0
- package/dist/tui-context-runtime.d.ts.map +1 -0
- package/dist/tui-context-runtime.js +65 -0
- package/dist/tui-data-types.d.ts +923 -0
- package/dist/tui-data-types.d.ts.map +1 -0
- package/dist/tui-data-types.js +0 -0
- package/dist/tui-details-runtime.d.ts +25 -0
- package/dist/tui-details-runtime.d.ts.map +1 -0
- package/dist/tui-details-runtime.js +29 -0
- package/dist/tui-memory-runtime.d.ts +33 -0
- package/dist/tui-memory-runtime.d.ts.map +1 -0
- package/dist/tui-memory-runtime.js +58 -0
- package/dist/tui-messages.d.ts +4 -0
- package/dist/tui-messages.d.ts.map +1 -0
- package/dist/tui-messages.js +6 -0
- package/dist/tui-model-runtime.d.ts +30 -0
- package/dist/tui-model-runtime.d.ts.map +1 -0
- package/dist/tui-model-runtime.js +39 -0
- package/dist/tui-output-surface.d.ts +141 -0
- package/dist/tui-output-surface.d.ts.map +1 -0
- package/dist/tui-output-surface.js +55 -0
- package/dist/tui-permission-runtime.d.ts +62 -0
- package/dist/tui-permission-runtime.d.ts.map +1 -0
- package/dist/tui-permission-runtime.js +24 -0
- package/dist/tui-state-runtime.d.ts +21 -0
- package/dist/tui-state-runtime.d.ts.map +1 -0
- package/dist/tui-state-runtime.js +47 -0
- package/dist/turn-continuity-runtime.d.ts +30 -0
- package/dist/turn-continuity-runtime.d.ts.map +1 -0
- package/dist/turn-continuity-runtime.js +8 -0
- package/dist/undo-ring.d.ts +16 -0
- package/dist/undo-ring.d.ts.map +1 -0
- package/dist/undo-ring.js +12 -0
- package/dist/usage-stats-presenter.d.ts +17 -0
- package/dist/usage-stats-presenter.d.ts.map +1 -0
- package/dist/usage-stats-presenter.js +22 -0
- package/dist/user-state-signal-runtime.d.ts +33 -0
- package/dist/user-state-signal-runtime.d.ts.map +1 -0
- package/dist/user-state-signal-runtime.js +8 -0
- package/dist/verification-command-runtime.d.ts +25 -0
- package/dist/verification-command-runtime.d.ts.map +1 -0
- package/dist/verification-command-runtime.js +51 -0
- package/dist/verification-level.d.ts +93 -0
- package/dist/verification-level.d.ts.map +1 -0
- package/dist/verification-level.js +18 -0
- package/dist/workflow-agent-runtime-bridge.d.ts +169 -0
- package/dist/workflow-agent-runtime-bridge.d.ts.map +1 -0
- package/dist/workflow-agent-runtime-bridge.js +9 -0
- package/dist/workflow-command-runtime.d.ts +94 -0
- package/dist/workflow-command-runtime.d.ts.map +1 -0
- package/dist/workflow-command-runtime.js +114 -0
- package/dist/workflow-plan-schema.d.ts +161 -0
- package/dist/workflow-plan-schema.d.ts.map +1 -0
- package/dist/workflow-plan-schema.js +12 -0
- package/dist/workflow-planner-entry.d.ts +52 -0
- package/dist/workflow-planner-entry.d.ts.map +1 -0
- package/dist/workflow-planner-entry.js +328 -0
- package/dist/workflow-task-surface.d.ts +39 -0
- package/dist/workflow-task-surface.d.ts.map +1 -0
- package/dist/workflow-task-surface.js +7 -0
- package/dist/workspace-reference-cache.d.ts +110 -0
- package/dist/workspace-reference-cache.d.ts.map +1 -0
- package/dist/workspace-reference-cache.js +12 -0
- package/package.json +41 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
charWidth
|
|
3
|
+
} from "./chunk-APJIC2O5.js";
|
|
4
|
+
|
|
5
|
+
// src/shell/models/transcript-selection-state.ts
|
|
6
|
+
import {
|
|
7
|
+
isTerminalSelectionMouseInput,
|
|
8
|
+
isTerminalSelectionStale,
|
|
9
|
+
parseTerminalSelectionMouseEvent,
|
|
10
|
+
reduceTerminalSelection,
|
|
11
|
+
terminalSelectedTextFromRows,
|
|
12
|
+
terminalSelectionContainsRow,
|
|
13
|
+
terminalSelectionLineIndexesForBlock,
|
|
14
|
+
terminalSelectionLineRangesForBlock
|
|
15
|
+
} from "@linghun/ink-runtime";
|
|
16
|
+
function buildTranscriptScreenBuffer(blocks, width = Number.POSITIVE_INFINITY) {
|
|
17
|
+
const rows = [];
|
|
18
|
+
for (const block of blocks) {
|
|
19
|
+
const noSelect = isNoSelectBlock(block);
|
|
20
|
+
const body = screenTextForBlock(block);
|
|
21
|
+
const lines = body.replace(/\r/g, "").split("\n");
|
|
22
|
+
for (let lineInBlock = 0; lineInBlock < lines.length; lineInBlock++) {
|
|
23
|
+
appendScreenRows(rows, {
|
|
24
|
+
blockId: block.id,
|
|
25
|
+
lineInBlock,
|
|
26
|
+
text: lines[lineInBlock] ?? "",
|
|
27
|
+
width,
|
|
28
|
+
noSelect
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (body.trim().length > 0) appendScreenRows(rows, { text: "", width, noSelect: true });
|
|
32
|
+
}
|
|
33
|
+
if (rows.length > 0 && rows.at(-1)?.text === "") rows.pop();
|
|
34
|
+
return { rows, width };
|
|
35
|
+
}
|
|
36
|
+
function buildTranscriptTextRows(blocks, width = Number.POSITIVE_INFINITY) {
|
|
37
|
+
return buildTranscriptScreenBuffer(blocks, width).rows;
|
|
38
|
+
}
|
|
39
|
+
function parseSgrMouseEvent(input) {
|
|
40
|
+
return parseTerminalSelectionMouseEvent(input);
|
|
41
|
+
}
|
|
42
|
+
function isSgrMouseInput(input) {
|
|
43
|
+
return isTerminalSelectionMouseInput(input);
|
|
44
|
+
}
|
|
45
|
+
function isSelectionStale(state, now) {
|
|
46
|
+
return isTerminalSelectionStale(state, now);
|
|
47
|
+
}
|
|
48
|
+
function reduceTranscriptSelection(input) {
|
|
49
|
+
return reduceTerminalSelection(input);
|
|
50
|
+
}
|
|
51
|
+
function selectionContainsRow(selection, rowIndex) {
|
|
52
|
+
return terminalSelectionContainsRow(selection, rowIndex);
|
|
53
|
+
}
|
|
54
|
+
function selectionLineIndexesForBlock(selection, rows, blockId) {
|
|
55
|
+
return terminalSelectionLineIndexesForBlock(selection, rows, blockId);
|
|
56
|
+
}
|
|
57
|
+
function selectionLineRangesForBlock(selection, rows, blockId) {
|
|
58
|
+
return terminalSelectionLineRangesForBlock(selection, rows, blockId).map(toProductBlockSelectionRange);
|
|
59
|
+
}
|
|
60
|
+
function selectedTextFromRows(rows, anchor, focus) {
|
|
61
|
+
return terminalSelectedTextFromRows(rows, anchor, focus);
|
|
62
|
+
}
|
|
63
|
+
function toProductBlockSelectionRange(range) {
|
|
64
|
+
return {
|
|
65
|
+
lineIndex: range.lineIndex,
|
|
66
|
+
startColumn: range.startColumn,
|
|
67
|
+
endColumn: range.endColumn
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function screenTextForBlock(block) {
|
|
71
|
+
if (block.messageKind === "user_text") return block.fullText ?? block.title ?? "";
|
|
72
|
+
return block.fullText ?? block.summary ?? block.title ?? "";
|
|
73
|
+
}
|
|
74
|
+
function isNoSelectBlock(block) {
|
|
75
|
+
if (block.messageKind === "command_transcript" || block.messageKind === "status") return true;
|
|
76
|
+
if (block.kind === "home" || block.kind === "setup" || block.kind === "permission") return true;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
function appendScreenRows(rows, input) {
|
|
80
|
+
const wrapWidth = Number.isFinite(input.width) ? Math.max(1, Math.floor(input.width)) : Infinity;
|
|
81
|
+
const sourceCells = cellsFromText(input.text, input.noSelect === true);
|
|
82
|
+
if (sourceCells.length === 0) {
|
|
83
|
+
rows.push({
|
|
84
|
+
index: rows.length,
|
|
85
|
+
blockId: input.blockId,
|
|
86
|
+
lineInBlock: input.lineInBlock,
|
|
87
|
+
text: "",
|
|
88
|
+
cells: [],
|
|
89
|
+
noSelect: input.noSelect
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let current = [];
|
|
94
|
+
let currentWidth = 0;
|
|
95
|
+
let sourceColumnStart = 0;
|
|
96
|
+
let softWrapped = false;
|
|
97
|
+
for (const cell of sourceCells) {
|
|
98
|
+
const nextWidth = Math.max(1, cell.width);
|
|
99
|
+
if (current.length > 0 && currentWidth + nextWidth > wrapWidth) {
|
|
100
|
+
rows.push(createScreenRow(rows.length, input, current, softWrapped, sourceColumnStart));
|
|
101
|
+
sourceColumnStart += current.length;
|
|
102
|
+
current = [];
|
|
103
|
+
currentWidth = 0;
|
|
104
|
+
softWrapped = true;
|
|
105
|
+
}
|
|
106
|
+
current.push(cell);
|
|
107
|
+
currentWidth += nextWidth;
|
|
108
|
+
}
|
|
109
|
+
rows.push(createScreenRow(rows.length, input, current, softWrapped, sourceColumnStart));
|
|
110
|
+
}
|
|
111
|
+
function createScreenRow(index, input, cells, softWrapped, sourceColumnStart) {
|
|
112
|
+
return {
|
|
113
|
+
index,
|
|
114
|
+
blockId: input.blockId,
|
|
115
|
+
lineInBlock: input.lineInBlock,
|
|
116
|
+
text: cells.map((cell) => cell.selectableText).join(""),
|
|
117
|
+
cells,
|
|
118
|
+
sourceColumnStart,
|
|
119
|
+
softWrapped,
|
|
120
|
+
noSelect: input.noSelect
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function cellsFromText(text, noSelect) {
|
|
124
|
+
const cells = [];
|
|
125
|
+
for (const char of Array.from(text)) {
|
|
126
|
+
const width = Math.max(1, charWidth(char));
|
|
127
|
+
cells.push({ char, selectableText: noSelect ? "" : char, width, noSelect });
|
|
128
|
+
for (let index = 1; index < width; index++) {
|
|
129
|
+
cells.push({ char: "", selectableText: "", width: 0, noSelect: true });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return cells;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
buildTranscriptScreenBuffer,
|
|
137
|
+
buildTranscriptTextRows,
|
|
138
|
+
parseSgrMouseEvent,
|
|
139
|
+
isSgrMouseInput,
|
|
140
|
+
isSelectionStale,
|
|
141
|
+
reduceTranscriptSelection,
|
|
142
|
+
selectionContainsRow,
|
|
143
|
+
selectionLineIndexesForBlock,
|
|
144
|
+
selectionLineRangesForBlock,
|
|
145
|
+
selectedTextFromRows
|
|
146
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// src/model-setup-runtime.ts
|
|
2
|
+
import { validateProviderEnvSetup } from "@linghun/config";
|
|
3
|
+
function getNextModelSetupStep(values) {
|
|
4
|
+
if (!values.baseUrl) return "baseUrl";
|
|
5
|
+
if (!values.apiKey) return "apiKey";
|
|
6
|
+
if (!values.model) return "model";
|
|
7
|
+
if (!values.reasoningLevel) return "reasoning";
|
|
8
|
+
return "confirm";
|
|
9
|
+
}
|
|
10
|
+
function parseModelSetupPrefill(text) {
|
|
11
|
+
const prefill = {};
|
|
12
|
+
const url = text.match(/https?:\/\/[^\s,,]+/iu)?.[0];
|
|
13
|
+
if (url) prefill.baseUrl = url;
|
|
14
|
+
const model = text.match(/(?:^|[\s,,;;])model(?:\s*[=::]\s*|\s+)([^\s,,;;]+)/iu)?.[1] ?? text.match(/(?:^|[\s,,;;])模型(?:\s*[=::]\s*|\s+)([^\s,,;;]+)/iu)?.[1];
|
|
15
|
+
if (model) prefill.model = model;
|
|
16
|
+
const reasoning = text.match(
|
|
17
|
+
/(?:reasoning|推理等级|推理)\s*[=::]?\s*(Low|Medium|High|低|中|高)/iu
|
|
18
|
+
)?.[1];
|
|
19
|
+
if (reasoning) prefill.reasoningLevel = normalizeModelSetupReasoningLevel(reasoning);
|
|
20
|
+
const key = text.match(/(?:api\s*key|apikey|key|密钥)\s*[=::]?\s*([^\s,,;;]+)/iu)?.[1] ?? text.match(/\b(sk-[A-Za-z0-9._-]{8,})\b/u)?.[1];
|
|
21
|
+
if (key) prefill.apiKey = key;
|
|
22
|
+
return prefill;
|
|
23
|
+
}
|
|
24
|
+
function normalizeModelSetupReasoningLevel(value) {
|
|
25
|
+
const normalized = value.trim().toLowerCase();
|
|
26
|
+
if (normalized === "low" || normalized === "\u4F4E") return "Low";
|
|
27
|
+
if (normalized === "high" || normalized === "\u9AD8") return "High";
|
|
28
|
+
return "Medium";
|
|
29
|
+
}
|
|
30
|
+
function looksLikeModelSetupInput(text) {
|
|
31
|
+
const prefill = parseModelSetupPrefill(text);
|
|
32
|
+
if (/正常|状态|doctor|检查|诊断|怎么样|是否|吗|\?|?/iu.test(text)) {
|
|
33
|
+
return Object.keys(prefill).length > 0;
|
|
34
|
+
}
|
|
35
|
+
return /配置.*(?:模型|api\s*key|key|provider|供应商)|设置.*(?:模型|api\s*key|key|provider|供应商)|我要配置模型|configure\s+(?:model|provider|api\s*key)|setup\s+(?:model|provider)|model\s+setup|api\s*key|apikey/iu.test(
|
|
36
|
+
text
|
|
37
|
+
) || Object.keys(prefill).length > 0;
|
|
38
|
+
}
|
|
39
|
+
function applyModelSetupValues(setup, values) {
|
|
40
|
+
const next = { ...setup.values, ...values };
|
|
41
|
+
validateModelSetupPartial(next);
|
|
42
|
+
setup.values = next;
|
|
43
|
+
}
|
|
44
|
+
function validateModelSetupPartial(values) {
|
|
45
|
+
if (values.baseUrl !== void 0) {
|
|
46
|
+
validateProviderEnvSetup({
|
|
47
|
+
baseUrl: values.baseUrl,
|
|
48
|
+
apiKey: "temporary-validation-key",
|
|
49
|
+
model: "temporary-model",
|
|
50
|
+
reasoningLevel: "Medium"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (values.apiKey !== void 0) {
|
|
54
|
+
validateProviderEnvSetup({
|
|
55
|
+
baseUrl: "https://example.com/v1",
|
|
56
|
+
apiKey: values.apiKey,
|
|
57
|
+
model: "temporary-model",
|
|
58
|
+
reasoningLevel: "Medium"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (values.model !== void 0 || values.reasoningLevel !== void 0) {
|
|
62
|
+
validateProviderEnvSetup({
|
|
63
|
+
baseUrl: "https://example.com/v1",
|
|
64
|
+
apiKey: "temporary-validation-key",
|
|
65
|
+
model: values.model ?? "temporary-model",
|
|
66
|
+
reasoningLevel: values.reasoningLevel ?? "Medium",
|
|
67
|
+
endpointProfile: values.endpointProfile,
|
|
68
|
+
includeUsage: values.includeUsage,
|
|
69
|
+
auxModel: values.auxModel
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function getModelSetupPromptMessage(setup, language) {
|
|
74
|
+
const keyByStep = {
|
|
75
|
+
baseUrl: "baseUrlPrompt",
|
|
76
|
+
apiKey: "apiKeyPrompt",
|
|
77
|
+
model: "modelPrompt",
|
|
78
|
+
reasoning: "reasoningPrompt",
|
|
79
|
+
auxModel: "auxModelPrompt",
|
|
80
|
+
confirm: "confirmPrompt"
|
|
81
|
+
};
|
|
82
|
+
return formatModelSetupMessage(keyByStep[setup.step], language, setup);
|
|
83
|
+
}
|
|
84
|
+
function formatModelSetupMessage(key, language, setup) {
|
|
85
|
+
const english = language === "en-US";
|
|
86
|
+
const messagesByKey = {
|
|
87
|
+
intro: english ? [
|
|
88
|
+
"Model setup wizard",
|
|
89
|
+
"- One-time setup for this computer; other repositories will reuse the same user provider.env.",
|
|
90
|
+
"- API key is saved in the private user provider.env, never in project .linghun/settings.json.",
|
|
91
|
+
`- Save location: ${setup.providerEnvPath}`,
|
|
92
|
+
setup.createdTemplate ? "- A commented template was created for manual edits later." : ""
|
|
93
|
+
].filter(Boolean).join("\n") : [
|
|
94
|
+
"\u6A21\u578B\u914D\u7F6E\u5411\u5BFC",
|
|
95
|
+
"- \u8FD9\u662F\u672C\u673A\u4E00\u6B21\u914D\u7F6E\uFF1B\u914D\u7F6E\u540E\u5176\u4ED6\u4ED3\u5E93\u4F1A\u9ED8\u8BA4\u590D\u7528\u540C\u4E00\u4E2A\u7528\u6237 provider.env\u3002",
|
|
96
|
+
"- API key \u4F1A\u5199\u5165\u672C\u673A\u7528\u6237\u79C1\u5BC6 provider.env\uFF0C\u4E0D\u4F1A\u5199\u5165\u9879\u76EE .linghun/settings.json\u3002",
|
|
97
|
+
`- \u5199\u5165\u4F4D\u7F6E\uFF1A${setup.providerEnvPath}`,
|
|
98
|
+
setup.createdTemplate ? "- \u5DF2\u521B\u5EFA\u5E26\u6CE8\u91CA\u6A21\u677F\uFF0C\u540E\u7EED\u53EF\u76F4\u63A5\u7F16\u8F91\u8FD9\u4E2A\u6587\u4EF6\u3002" : ""
|
|
99
|
+
].filter(Boolean).join("\n"),
|
|
100
|
+
baseUrlPrompt: english ? "API base URL is missing. Enter the root API URL, for example https://example.com/v1." : "\u7F3A\u5C11 API \u5730\u5740\u3002\u8BF7\u8F93\u5165 root API \u5730\u5740\uFF0C\u4F8B\u5982 https://example.com/v1\u3002",
|
|
101
|
+
apiKeyPrompt: english ? "API key is missing. Enter it now; input is masked when possible and the raw value will not be printed." : "\u7F3A\u5C11 API key\u3002\u8BF7\u8F93\u5165 API key\uFF08\u8F93\u5165\u65F6\u4F1A\u5C3D\u91CF mask\uFF0C\u4E0D\u663E\u793A\u539F\u503C\uFF09\u3002",
|
|
102
|
+
modelPrompt: english ? "Model name is missing. Enter the model name." : "\u7F3A\u5C11\u6A21\u578B\u540D\u79F0\u3002\u8BF7\u8F93\u5165\u6A21\u578B\u540D\u79F0\u3002",
|
|
103
|
+
reasoningPrompt: english ? "Reasoning level: Low / Medium / High. Press Enter to use Medium." : "\u63A8\u7406\u7B49\u7EA7\u53EF\u9009 Low / Medium / High\uFF0C\u9ED8\u8BA4 Medium\u3002\u76F4\u63A5\u56DE\u8F66\u4F7F\u7528 Medium\u3002",
|
|
104
|
+
auxModelPrompt: english ? "Auxiliary model is optional. Press Enter to let helper roles follow the main model." : "\u8F85\u52A9\u6A21\u578B\u53EF\u9009\uFF0C\u76F4\u63A5\u56DE\u8F66\u5219\u8DDF\u968F\u4E3B\u6A21\u578B\u3002",
|
|
105
|
+
confirmPrompt: english ? "Type yes/save to save, no to cancel, or details for safety notes." : "\u8BF7\u8F93\u5165 yes \u4FDD\u5B58\uFF0Cno \u53D6\u6D88\uFF0Cdetails \u67E5\u770B\u5B89\u5168\u8BF4\u660E\u3002",
|
|
106
|
+
cancelled: english ? "Model setup cancelled. No key was saved." : "\u5DF2\u53D6\u6D88\u6A21\u578B\u914D\u7F6E\uFF0C\u672A\u4FDD\u5B58\u4EFB\u4F55 key\u3002",
|
|
107
|
+
details: english ? [
|
|
108
|
+
"Safety notes",
|
|
109
|
+
`- provider.env path: ${setup.providerEnvPath}`,
|
|
110
|
+
"- Shell env has highest priority, then user provider.env, then existing settings/default.",
|
|
111
|
+
"- The raw key is not displayed and is not written to project settings, docs, reports, or logs.",
|
|
112
|
+
"- Role routes can stay unset; they follow the main model by default."
|
|
113
|
+
].join("\n") : [
|
|
114
|
+
"\u5B89\u5168\u8BF4\u660E",
|
|
115
|
+
`- provider.env \u8DEF\u5F84\uFF1A${setup.providerEnvPath}`,
|
|
116
|
+
"- shell env \u53D8\u91CF\u4F18\u5148\u7EA7\u6700\u9AD8\uFF0C\u5176\u6B21\u7528\u6237 provider.env\uFF0C\u518D\u8D70\u73B0\u6709 settings/default\u3002",
|
|
117
|
+
"- \u771F\u5B9E key \u4E0D\u4F1A\u663E\u793A\u3001\u4E0D\u5199\u5165\u9879\u76EE settings\u3001\u4E0D\u5199\u5165\u6587\u6863\u6216\u62A5\u544A\u3002",
|
|
118
|
+
"- \u4E0D\u8BBE\u7F6E\u89D2\u8272\u8DEF\u7531\u4E5F\u53EF\u4EE5\u6B63\u5E38\u4F7F\u7528\uFF0C\u89D2\u8272\u9ED8\u8BA4\u8DDF\u968F\u4E3B\u6A21\u578B\u3002"
|
|
119
|
+
].join("\n")
|
|
120
|
+
};
|
|
121
|
+
return messagesByKey[key];
|
|
122
|
+
}
|
|
123
|
+
function formatModelSetupFallbackError(language) {
|
|
124
|
+
return language === "en-US" ? "Validation failed. Complete the missing fields and try again." : "\u68C0\u67E5\u672A\u901A\u8FC7\uFF0C\u8BF7\u8865\u5168\u7F3A\u5931\u9879\u3002";
|
|
125
|
+
}
|
|
126
|
+
function formatModelSetupSummary(setup, language) {
|
|
127
|
+
const english = language === "en-US";
|
|
128
|
+
return [
|
|
129
|
+
english ? "Model setup summary" : "\u6A21\u578B\u914D\u7F6E\u6458\u8981",
|
|
130
|
+
"- provider openai-compatible",
|
|
131
|
+
`- base URL ${setup.values.baseUrl ? "present" : "missing"}`,
|
|
132
|
+
`- api key ${setup.values.apiKey ? "present" : "missing"}`,
|
|
133
|
+
`- model ${setup.values.model ?? "missing"}`,
|
|
134
|
+
`- reasoning level ${setup.values.reasoningLevel ?? "Medium"}`,
|
|
135
|
+
`${english ? "- save location" : "- \u5199\u5165\u4F4D\u7F6E"}\uFF1A${setup.providerEnvPath}`,
|
|
136
|
+
english ? "Type yes/save to save. The raw API key is not shown." : "\u8BF7\u8F93\u5165 yes/\u4FDD\u5B58 \u786E\u8BA4\u540E\u624D\u4F1A\u5199\u5165\uFF1B\u6458\u8981\u4E0D\u4F1A\u663E\u793A key \u539F\u503C\u3002"
|
|
137
|
+
].join("\n");
|
|
138
|
+
}
|
|
139
|
+
function formatModelSetupSaved(path, language) {
|
|
140
|
+
return language === "en-US" ? [
|
|
141
|
+
"Saved. Restart Linghun to use the new user provider config.",
|
|
142
|
+
`- User provider.env: ${path}`,
|
|
143
|
+
"- This is user-scoped and will be reused by other repositories by default.",
|
|
144
|
+
"- To change API URL, key, or model later, run /model setup or edit provider.env.",
|
|
145
|
+
"- Check configuration with /model doctor."
|
|
146
|
+
].join("\n") : [
|
|
147
|
+
"\u5DF2\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u542F Linghun \u540E\u4F7F\u7528\u65B0\u7684\u7528\u6237\u7EA7 provider \u914D\u7F6E\u3002",
|
|
148
|
+
`- \u7528\u6237 provider.env\uFF1A${path}`,
|
|
149
|
+
"- \u8FD9\u662F\u7528\u6237\u7EA7\u914D\u7F6E\uFF0C\u4E4B\u540E\u8FDB\u5165\u5176\u4ED6\u4ED3\u5E93\u4F1A\u9ED8\u8BA4\u590D\u7528\u3002",
|
|
150
|
+
"- \u540E\u7EED\u60F3\u66F4\u6362 API \u5730\u5740\u3001key \u6216\u6A21\u578B\u540D\u79F0\uFF0C\u53EF\u8FD0\u884C /model setup\uFF0C\u6216\u7F16\u8F91\u4E0A\u8FF0 provider.env\u3002",
|
|
151
|
+
"- \u68C0\u67E5\u914D\u7F6E\u53EF\u8FD0\u884C /model doctor\u3002"
|
|
152
|
+
].join("\n");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
getNextModelSetupStep,
|
|
157
|
+
parseModelSetupPrefill,
|
|
158
|
+
normalizeModelSetupReasoningLevel,
|
|
159
|
+
looksLikeModelSetupInput,
|
|
160
|
+
applyModelSetupValues,
|
|
161
|
+
validateModelSetupPartial,
|
|
162
|
+
getModelSetupPromptMessage,
|
|
163
|
+
formatModelSetupMessage,
|
|
164
|
+
formatModelSetupFallbackError,
|
|
165
|
+
formatModelSetupSummary,
|
|
166
|
+
formatModelSetupSaved
|
|
167
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/shell/models/permission-explanation.ts
|
|
2
|
+
function sanitizePermissionReason(reason) {
|
|
3
|
+
if (!reason) return "";
|
|
4
|
+
return reason.replace(
|
|
5
|
+
/命中\s*(deny|ask|allow)\s*规则[::].*/gu,
|
|
6
|
+
(_match, effect) => effect === "deny" ? "\u547D\u4E2D\u62D2\u7EDD\u89C4\u5219\u3002" : effect === "ask" ? "\u547D\u4E2D\u9700\u786E\u8BA4\u89C4\u5219\u3002" : "\u547D\u4E2D\u5141\u8BB8\u89C4\u5219\u3002"
|
|
7
|
+
).replace(
|
|
8
|
+
/Hit\s+(deny|ask|allow)\s+rule:.*/giu,
|
|
9
|
+
(_match, effect) => effect.toLowerCase() === "deny" ? "Hit deny rule." : effect.toLowerCase() === "ask" ? "Hit ask rule." : "Hit allow rule."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
function explainSemantic(semantic, language) {
|
|
13
|
+
const isEn = language === "en-US";
|
|
14
|
+
switch (semantic) {
|
|
15
|
+
case "readonly":
|
|
16
|
+
return isEn ? "Read-only operation." : "\u53EA\u8BFB\u64CD\u4F5C\u3002";
|
|
17
|
+
case "mutating":
|
|
18
|
+
return isEn ? "May change workspace files." : "\u53EF\u80FD\u4FEE\u6539\u5DE5\u4F5C\u533A\u6587\u4EF6\u3002";
|
|
19
|
+
case "destructive":
|
|
20
|
+
return isEn ? "Destructive command (delete / overwrite / shutdown)." : "\u7834\u574F\u6027\u547D\u4EE4\uFF08\u5220\u9664 / \u8986\u76D6 / \u5173\u505C\uFF09\u3002";
|
|
21
|
+
case "network":
|
|
22
|
+
return isEn ? "Performs network calls." : "\u4F1A\u53D1\u8D77\u7F51\u7EDC\u8BF7\u6C42\u3002";
|
|
23
|
+
case "install":
|
|
24
|
+
return isEn ? "Installs or updates dependencies." : "\u5B89\u88C5\u6216\u66F4\u65B0\u4F9D\u8D56\u3002";
|
|
25
|
+
case "secret_read":
|
|
26
|
+
return isEn ? "Reads sensitive files." : "\u8BFB\u53D6\u654F\u611F\u6587\u4EF6\u3002";
|
|
27
|
+
case "outside_workspace":
|
|
28
|
+
return isEn ? "Touches paths outside the workspace." : "\u6D89\u53CA\u5DE5\u4F5C\u533A\u5916\u7684\u8DEF\u5F84\u3002";
|
|
29
|
+
default:
|
|
30
|
+
return isEn ? "Action requires confirmation." : "\u9700\u8981\u786E\u8BA4\u540E\u518D\u6267\u884C\u3002";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function explainPathSafety(pathSafety, language) {
|
|
34
|
+
const isEn = language === "en-US";
|
|
35
|
+
switch (pathSafety) {
|
|
36
|
+
case "workspace_safe":
|
|
37
|
+
return isEn ? "Path is workspace-safe." : "\u8DEF\u5F84\u5728\u5DE5\u4F5C\u533A\u4E14\u5B89\u5168\u3002";
|
|
38
|
+
case "workspace_write":
|
|
39
|
+
return isEn ? "Writes inside the workspace." : "\u5728\u5DE5\u4F5C\u533A\u5185\u5199\u5165\u3002";
|
|
40
|
+
case "outside_workspace":
|
|
41
|
+
return isEn ? "Touches paths outside the workspace." : "\u6D89\u53CA\u5DE5\u4F5C\u533A\u5916\u8DEF\u5F84\u3002";
|
|
42
|
+
case "sensitive_path":
|
|
43
|
+
return isEn ? "Touches a sensitive path." : "\u6D89\u53CA\u654F\u611F\u8DEF\u5F84\u3002";
|
|
44
|
+
default:
|
|
45
|
+
return isEn ? "Path classification unknown." : "\u8DEF\u5F84\u5206\u7C7B\u672A\u77E5\u3002";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function explainHowToUpdate(language) {
|
|
49
|
+
return language === "en-US" ? "Use /permissions to update rules." : "\u53EF\u7528 /permissions \u67E5\u770B\u4E0E\u8C03\u6574\u89C4\u5219\u3002";
|
|
50
|
+
}
|
|
51
|
+
function explainPolicyVerdict(verdict, language) {
|
|
52
|
+
const lines = [];
|
|
53
|
+
if (verdict.semantic) lines.push(explainSemantic(verdict.semantic, language));
|
|
54
|
+
if (verdict.pathSafety) lines.push(explainPathSafety(verdict.pathSafety, language));
|
|
55
|
+
if (verdict.redactedSummary && verdict.redactedSummary.trim().length > 0) {
|
|
56
|
+
lines.push(verdict.redactedSummary.trim());
|
|
57
|
+
}
|
|
58
|
+
if (verdict.reason) {
|
|
59
|
+
const safe = sanitizePermissionReason(verdict.reason).trim();
|
|
60
|
+
if (safe.length > 0 && !lines.some((existing) => existing === safe)) {
|
|
61
|
+
lines.push(safe);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
lines.push(explainHowToUpdate(language));
|
|
65
|
+
return lines;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
sanitizePermissionReason,
|
|
70
|
+
explainSemantic,
|
|
71
|
+
explainPathSafety,
|
|
72
|
+
explainHowToUpdate,
|
|
73
|
+
explainPolicyVerdict
|
|
74
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/memory-eviction-runtime.ts
|
|
2
|
+
var AGENT_KEEP_RECENT = 5;
|
|
3
|
+
var AGENT_FULL_REPORT_MAX_CHARS = 400;
|
|
4
|
+
var BLOCK_KEEP_RECENT = 60;
|
|
5
|
+
var BLOCK_FULLTEXT_EVICT_CHARS = 200;
|
|
6
|
+
var TOOL_BUDGET_STATE_MAX_ENTRIES = 200;
|
|
7
|
+
function evictCompletedAgents(context) {
|
|
8
|
+
const agents = context.agents;
|
|
9
|
+
if (agents.length <= AGENT_KEEP_RECENT) return;
|
|
10
|
+
const terminal = (a) => a.status === "completed" || a.status === "failed" || a.status === "cancelled";
|
|
11
|
+
let evictCount = 0;
|
|
12
|
+
for (let i = agents.length - 1; i >= 0; i--) {
|
|
13
|
+
const agent = agents[i];
|
|
14
|
+
if (!agent || !terminal(agent)) continue;
|
|
15
|
+
evictCount++;
|
|
16
|
+
if (evictCount <= AGENT_KEEP_RECENT) continue;
|
|
17
|
+
if (agent.lastResultFullReport && agent.lastResultFullReport.length > AGENT_FULL_REPORT_MAX_CHARS) {
|
|
18
|
+
agent.lastResultFullReport = agent.lastResultFullReport.slice(0, AGENT_FULL_REPORT_MAX_CHARS) + "\u2026[evicted]";
|
|
19
|
+
}
|
|
20
|
+
agent.mailbox = [];
|
|
21
|
+
agent.contextSummary = "";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function evictCommittedBlocks(blocks) {
|
|
25
|
+
if (blocks.length <= BLOCK_KEEP_RECENT) return;
|
|
26
|
+
const evictBefore = blocks.length - BLOCK_KEEP_RECENT;
|
|
27
|
+
for (let i = 0; i < evictBefore; i++) {
|
|
28
|
+
const block = blocks[i];
|
|
29
|
+
if (!block) continue;
|
|
30
|
+
if (block.fullText && block.fullText.length > BLOCK_FULLTEXT_EVICT_CHARS) {
|
|
31
|
+
block.fullText = block.fullText.slice(0, BLOCK_FULLTEXT_EVICT_CHARS) + "\u2026[evicted]";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function pruneToolResultBudgetState(context) {
|
|
36
|
+
const state = context.toolResultBudgetState;
|
|
37
|
+
if (!state) return;
|
|
38
|
+
if (state.seenIds.size <= TOOL_BUDGET_STATE_MAX_ENTRIES) return;
|
|
39
|
+
const idsArray = [...state.seenIds];
|
|
40
|
+
const removeCount = idsArray.length - TOOL_BUDGET_STATE_MAX_ENTRIES;
|
|
41
|
+
for (let i = 0; i < removeCount; i++) {
|
|
42
|
+
const id = idsArray[i];
|
|
43
|
+
if (id) {
|
|
44
|
+
state.seenIds.delete(id);
|
|
45
|
+
state.replacements.delete(id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function runMemoryEviction(context, blocks) {
|
|
50
|
+
evictCompletedAgents(context);
|
|
51
|
+
evictCommittedBlocks(blocks);
|
|
52
|
+
pruneToolResultBudgetState(context);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
evictCompletedAgents,
|
|
57
|
+
evictCommittedBlocks,
|
|
58
|
+
pruneToolResultBudgetState,
|
|
59
|
+
runMemoryEviction
|
|
60
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LINGHUN_DEFAULT_TOOL_RESULT_CHARS,
|
|
3
|
+
LINGHUN_MAX_TOOL_RESULTS_PER_MESSAGE_CHARS,
|
|
4
|
+
LINGHUN_MAX_TOOL_RESULT_BYTES
|
|
5
|
+
} from "./chunk-IWUIOLMF.js";
|
|
6
|
+
|
|
7
|
+
// src/tool-result-budget.ts
|
|
8
|
+
import { createHash, randomUUID } from "crypto";
|
|
9
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
10
|
+
import { basename, join, relative } from "path";
|
|
11
|
+
var TOOL_RESULTS_DIR = "tool-results";
|
|
12
|
+
var TOOL_RESULT_PREVIEW_CHARS = 2e3;
|
|
13
|
+
async function applyToolResultBudgetToMessages(messages, options) {
|
|
14
|
+
const candidates = collectToolResultCandidates(messages, options.state);
|
|
15
|
+
if (candidates.length === 0) return { messages, records: [] };
|
|
16
|
+
const cachedReplacements = /* @__PURE__ */ new Map();
|
|
17
|
+
const freshCandidates = [];
|
|
18
|
+
for (const candidate of candidates) {
|
|
19
|
+
const stateKey = options.state ? getCandidateStateKey(candidate, options.sessionId) : void 0;
|
|
20
|
+
const existing = stateKey ? options.state?.replacements.get(stateKey) : void 0;
|
|
21
|
+
if (existing) {
|
|
22
|
+
cachedReplacements.set(candidate.toolUseId, existing.summary);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (stateKey && options.state?.seenIds.has(stateKey)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
freshCandidates.push(candidate);
|
|
29
|
+
}
|
|
30
|
+
const selected = /* @__PURE__ */ new Map();
|
|
31
|
+
for (const candidate of freshCandidates) {
|
|
32
|
+
if (candidate.chars > LINGHUN_DEFAULT_TOOL_RESULT_CHARS || candidate.bytes > LINGHUN_MAX_TOOL_RESULT_BYTES) {
|
|
33
|
+
selected.set(candidate.toolUseId, { ...candidate, reason: "single_result" });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const freshIds = new Set(freshCandidates.map((candidate) => candidate.toolUseId));
|
|
37
|
+
for (const group of groupCandidatesByAssistantToolUse(messages, candidates)) {
|
|
38
|
+
const visibleSize = group.reduce((sum, candidate) => {
|
|
39
|
+
const stateKey = options.state ? getCandidateStateKey(candidate, options.sessionId) : void 0;
|
|
40
|
+
const replacement = stateKey ? options.state?.replacements.get(stateKey) : void 0;
|
|
41
|
+
return sum + (replacement?.summary.length ?? candidate.chars);
|
|
42
|
+
}, 0);
|
|
43
|
+
if (visibleSize <= LINGHUN_MAX_TOOL_RESULTS_PER_MESSAGE_CHARS) continue;
|
|
44
|
+
let remaining = visibleSize;
|
|
45
|
+
for (const candidate of [...group].filter((item) => freshIds.has(item.toolUseId)).sort((a, b) => b.chars - a.chars)) {
|
|
46
|
+
if (remaining <= LINGHUN_MAX_TOOL_RESULTS_PER_MESSAGE_CHARS) break;
|
|
47
|
+
if (!selected.has(candidate.toolUseId)) {
|
|
48
|
+
selected.set(candidate.toolUseId, { ...candidate, reason: "aggregate_message" });
|
|
49
|
+
}
|
|
50
|
+
remaining -= candidate.chars;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (selected.size === 0) {
|
|
54
|
+
for (const candidate of freshCandidates) {
|
|
55
|
+
options.state?.seenIds.add(getCandidateStateKey(candidate, options.sessionId));
|
|
56
|
+
}
|
|
57
|
+
return cachedReplacements.size === 0 ? { messages, records: [] } : { messages: replaceToolResults(messages, cachedReplacements), records: [] };
|
|
58
|
+
}
|
|
59
|
+
const replacements = new Map(cachedReplacements);
|
|
60
|
+
const records = [];
|
|
61
|
+
for (const candidate of selected.values()) {
|
|
62
|
+
const artifact = await writeToolResultArtifact(candidate, options);
|
|
63
|
+
const replacement = buildToolResultBudgetSummary(artifact, candidate.reason);
|
|
64
|
+
replacements.set(candidate.toolUseId, replacement);
|
|
65
|
+
const record = {
|
|
66
|
+
toolUseId: candidate.toolUseId,
|
|
67
|
+
originalChars: candidate.content.length,
|
|
68
|
+
replacementChars: replacement.length,
|
|
69
|
+
artifact,
|
|
70
|
+
reason: candidate.reason
|
|
71
|
+
};
|
|
72
|
+
records.push(record);
|
|
73
|
+
const stateKey = getCandidateStateKey(candidate, options.sessionId);
|
|
74
|
+
options.state?.replacements.set(stateKey, {
|
|
75
|
+
summary: replacement,
|
|
76
|
+
record,
|
|
77
|
+
fingerprint: stateKey
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
for (const candidate of freshCandidates) {
|
|
81
|
+
options.state?.seenIds.add(getCandidateStateKey(candidate, options.sessionId));
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
messages: replaceToolResults(messages, replacements),
|
|
85
|
+
records
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function collectToolResultCandidates(messages, _state) {
|
|
89
|
+
const candidates = [];
|
|
90
|
+
messages.forEach((message, messageIndex) => {
|
|
91
|
+
if (message.role !== "tool") return;
|
|
92
|
+
if (isBudgetSummary(message.content)) return;
|
|
93
|
+
const bytes = Buffer.byteLength(message.content, "utf8");
|
|
94
|
+
candidates.push({
|
|
95
|
+
messageIndex,
|
|
96
|
+
toolUseId: message.tool_call_id,
|
|
97
|
+
content: message.content,
|
|
98
|
+
chars: message.content.length,
|
|
99
|
+
bytes
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
return candidates;
|
|
103
|
+
}
|
|
104
|
+
function getCandidateStateKey(candidate, sessionId) {
|
|
105
|
+
candidate.stateKey ??= [
|
|
106
|
+
sessionId,
|
|
107
|
+
candidate.toolUseId,
|
|
108
|
+
candidate.chars,
|
|
109
|
+
candidate.bytes,
|
|
110
|
+
createHash("sha256").update(candidate.content).digest("hex")
|
|
111
|
+
].join("\0");
|
|
112
|
+
return candidate.stateKey;
|
|
113
|
+
}
|
|
114
|
+
function groupCandidatesByAssistantToolUse(messages, candidates) {
|
|
115
|
+
const byMessageIndex = new Map(
|
|
116
|
+
candidates.map((candidate) => [candidate.messageIndex, candidate])
|
|
117
|
+
);
|
|
118
|
+
const groups = [];
|
|
119
|
+
for (let index = 0; index < messages.length; index += 1) {
|
|
120
|
+
const message = messages[index];
|
|
121
|
+
if (message.role !== "assistant" || !message.toolCalls?.length) continue;
|
|
122
|
+
const ids = new Set(message.toolCalls.map((toolCall) => toolCall.id));
|
|
123
|
+
const group = [];
|
|
124
|
+
for (let cursor = index + 1; cursor < messages.length; cursor += 1) {
|
|
125
|
+
const next = messages[cursor];
|
|
126
|
+
if (next.role === "assistant") break;
|
|
127
|
+
if (next.role !== "tool") continue;
|
|
128
|
+
if (!ids.has(next.tool_call_id)) continue;
|
|
129
|
+
const candidate = byMessageIndex.get(cursor);
|
|
130
|
+
if (candidate) group.push(candidate);
|
|
131
|
+
}
|
|
132
|
+
if (group.length > 0) groups.push(group);
|
|
133
|
+
}
|
|
134
|
+
return groups;
|
|
135
|
+
}
|
|
136
|
+
async function writeToolResultArtifact(candidate, options) {
|
|
137
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
138
|
+
const dir = join(options.projectPath, ".linghun", "session", TOOL_RESULTS_DIR, options.sessionId);
|
|
139
|
+
await mkdir(dir, { recursive: true });
|
|
140
|
+
const sha256 = createHash("sha256").update(candidate.content).digest("hex");
|
|
141
|
+
const safeId = sanitizeId(candidate.toolUseId) || randomUUID();
|
|
142
|
+
const artifactId = `${safeId}-${sha256.slice(0, 12)}`;
|
|
143
|
+
const path = join(dir, `${artifactId}.txt`);
|
|
144
|
+
await writeFile(path, candidate.content, { encoding: "utf8", flag: "wx" }).catch(
|
|
145
|
+
async (error) => {
|
|
146
|
+
if (error.code !== "EEXIST") throw error;
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
const relativePath = relative(options.projectPath, path).replace(/\\/g, "/");
|
|
150
|
+
const preview = candidate.content.slice(0, TOOL_RESULT_PREVIEW_CHARS);
|
|
151
|
+
return {
|
|
152
|
+
id: artifactId,
|
|
153
|
+
toolUseId: candidate.toolUseId,
|
|
154
|
+
path,
|
|
155
|
+
relativePath,
|
|
156
|
+
bytes: candidate.bytes,
|
|
157
|
+
chars: candidate.content.length,
|
|
158
|
+
sha256,
|
|
159
|
+
previewChars: preview.length,
|
|
160
|
+
preview,
|
|
161
|
+
hasMore: preview.length < candidate.content.length
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function buildToolResultBudgetSummary(artifact, reason) {
|
|
165
|
+
return [
|
|
166
|
+
"<persisted-tool-result>",
|
|
167
|
+
`reason: ${reason}`,
|
|
168
|
+
`toolUseId: ${artifact.toolUseId}`,
|
|
169
|
+
`artifactId: ${artifact.id}`,
|
|
170
|
+
`artifactPath: ${artifact.relativePath}`,
|
|
171
|
+
`originalChars: ${artifact.chars}`,
|
|
172
|
+
`originalBytes: ${artifact.bytes}`,
|
|
173
|
+
`sha256: ${artifact.sha256}`,
|
|
174
|
+
`previewChars: ${artifact.previewChars}`,
|
|
175
|
+
"read: use /details output with the evidence id or read the artifact path if you need the full tool output.",
|
|
176
|
+
"preview:",
|
|
177
|
+
artifact.preview,
|
|
178
|
+
artifact.hasMore ? "..." : "",
|
|
179
|
+
"</persisted-tool-result>"
|
|
180
|
+
].filter((line) => line !== "").join("\n");
|
|
181
|
+
}
|
|
182
|
+
function replaceToolResults(messages, replacements) {
|
|
183
|
+
let changed = false;
|
|
184
|
+
const next = messages.map((message) => {
|
|
185
|
+
if (message.role !== "tool") return message;
|
|
186
|
+
const replacement = replacements.get(message.tool_call_id);
|
|
187
|
+
if (!replacement || replacement === message.content) return message;
|
|
188
|
+
changed = true;
|
|
189
|
+
return { ...message, content: replacement };
|
|
190
|
+
});
|
|
191
|
+
return changed ? next : messages;
|
|
192
|
+
}
|
|
193
|
+
function sanitizeId(value) {
|
|
194
|
+
return value.replace(/[^A-Za-z0-9_-]+/gu, "-").slice(0, 64);
|
|
195
|
+
}
|
|
196
|
+
function isBudgetSummary(content) {
|
|
197
|
+
return content.startsWith("<persisted-tool-result>");
|
|
198
|
+
}
|
|
199
|
+
function formatToolResultBudgetEvidenceSummary(record) {
|
|
200
|
+
return `tool_result persisted artifact=${record.artifact.relativePath} toolUseId=${record.toolUseId} chars=${record.originalChars} bytes=${record.artifact.bytes} sha256=${record.artifact.sha256}`;
|
|
201
|
+
}
|
|
202
|
+
function formatToolResultBudgetSystemEvent(record) {
|
|
203
|
+
return `tool_result_budget_persisted evidence artifact=${basename(record.artifact.path)} toolUseId=${record.toolUseId} reason=${record.reason} chars=${record.originalChars} sha256=${record.artifact.sha256}`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
applyToolResultBudgetToMessages,
|
|
208
|
+
formatToolResultBudgetEvidenceSummary,
|
|
209
|
+
formatToolResultBudgetSystemEvent
|
|
210
|
+
};
|