@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,407 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCompactBoundaryBlock
|
|
3
|
+
} from "./chunk-AKPXMCVF.js";
|
|
4
|
+
import {
|
|
5
|
+
createEvidenceRecord,
|
|
6
|
+
rememberEvidence
|
|
7
|
+
} from "./chunk-64MJP6FK.js";
|
|
8
|
+
import {
|
|
9
|
+
applyToolResultBudgetToMessages
|
|
10
|
+
} from "./chunk-O7S3HYE6.js";
|
|
11
|
+
import {
|
|
12
|
+
injectDeepCompactSummary,
|
|
13
|
+
maybeRunDeepCompactBeforeProvider
|
|
14
|
+
} from "./chunk-RMLTVKOY.js";
|
|
15
|
+
import {
|
|
16
|
+
getContextWindowForModel
|
|
17
|
+
} from "./chunk-K4FSYBSY.js";
|
|
18
|
+
import {
|
|
19
|
+
getRoleRoute
|
|
20
|
+
} from "./chunk-2YL5VKJ5.js";
|
|
21
|
+
import {
|
|
22
|
+
compactMessagesToFit
|
|
23
|
+
} from "./chunk-URNQUECO.js";
|
|
24
|
+
import {
|
|
25
|
+
estimateModelMessageChars
|
|
26
|
+
} from "./chunk-WV6YJGZR.js";
|
|
27
|
+
import {
|
|
28
|
+
sanitizeDiagnosticText,
|
|
29
|
+
sanitizeDisplayPaths,
|
|
30
|
+
truncateDisplay
|
|
31
|
+
} from "./chunk-OMZYPQVA.js";
|
|
32
|
+
|
|
33
|
+
// src/compact-preflight-runtime.ts
|
|
34
|
+
import "@linghun/providers";
|
|
35
|
+
import { redactCommonSecrets } from "@linghun/shared";
|
|
36
|
+
var MAX_CONTEXT_MESSAGES = 12;
|
|
37
|
+
var CONTEXT_INPUT_HEADROOM_TOKENS = 8192;
|
|
38
|
+
var CONTEXT_CHARS_PER_TOKEN_ESTIMATE = 4;
|
|
39
|
+
var AUTOCOMPACT_BUFFER_TOKENS = 13e3;
|
|
40
|
+
var LARGE_CONTEXT_BUFFER_TOKENS = 3e4;
|
|
41
|
+
var HUGE_CONTEXT_BUFFER_TOKENS = 5e4;
|
|
42
|
+
var LARGE_CONTEXT_WINDOW_TOKENS = 4e5;
|
|
43
|
+
var HUGE_CONTEXT_WINDOW_TOKENS = 8e5;
|
|
44
|
+
var COMPACT_FAILURE_COOLDOWN_MS = 2 * 60 * 1e3;
|
|
45
|
+
var COMPACT_SUMMARY_MAX_CHARS = 3200;
|
|
46
|
+
var COMPACT_SUMMARY_TARGET_RESERVE_CHARS = 4e3;
|
|
47
|
+
var COMPACT_PROJECTION_EVENT_PREFIX = "compact_projection:";
|
|
48
|
+
var MAX_COMPACT_BOUNDARIES = 20;
|
|
49
|
+
async function prepareMessagesForProviderPreflight(input) {
|
|
50
|
+
const budgeted = await prepareMessagesForProviderWithToolResultBudget(
|
|
51
|
+
input.messages,
|
|
52
|
+
input.context,
|
|
53
|
+
input.sessionId,
|
|
54
|
+
input.deps
|
|
55
|
+
);
|
|
56
|
+
const contextMaxChars = getProviderContextMaxChars(input.context, input.runtime);
|
|
57
|
+
const triggerChars = getAutoCompactTriggerChars(input.context, input.runtime);
|
|
58
|
+
const currentChars = estimateModelMessageChars(budgeted);
|
|
59
|
+
if (currentChars <= triggerChars) {
|
|
60
|
+
const withDeep = injectDeepCompactSummary(budgeted, input.context.cache.deepCompact);
|
|
61
|
+
if (estimateModelMessageChars(withDeep) <= contextMaxChars) {
|
|
62
|
+
return { blocked: false, messages: withDeep };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const now = Date.now();
|
|
66
|
+
if (input.context.cache.compactCooldownUntil && input.context.cache.compactCooldownUntil > now) {
|
|
67
|
+
const message = input.context.language === "en-US" ? "Context compact is cooling down after a previous failure. I will not send an oversized partial context to the provider; retry after the cooldown or run /compact status." : "\u4E0A\u4E00\u6B21\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\u540E\u4ECD\u5728\u51B7\u5374\u4E2D\u3002\u6211\u4E0D\u4F1A\u628A\u8D85\u538B\u7684\u534A\u622A\u4E0A\u4E0B\u6587\u7EE7\u7EED\u53D1\u7ED9 provider\uFF1B\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u8FD0\u884C /compact status \u67E5\u770B\u3002";
|
|
68
|
+
await input.deps.appendSystemEvent(
|
|
69
|
+
input.context,
|
|
70
|
+
input.sessionId,
|
|
71
|
+
"context_compact_cooldown_active",
|
|
72
|
+
"warning"
|
|
73
|
+
);
|
|
74
|
+
return { blocked: true, messages: budgeted, message };
|
|
75
|
+
}
|
|
76
|
+
const pairing = inspectToolPairingSafety(budgeted);
|
|
77
|
+
if (!pairing.safe) {
|
|
78
|
+
await input.deps.appendSystemEvent(
|
|
79
|
+
input.context,
|
|
80
|
+
input.sessionId,
|
|
81
|
+
`context_compact_skipped_tool_pairing: pending=${pairing.pending} orphan=${pairing.orphan} duplicate=${pairing.duplicate}`,
|
|
82
|
+
"warning"
|
|
83
|
+
);
|
|
84
|
+
if (currentChars > contextMaxChars) {
|
|
85
|
+
await recordCompactFailure(
|
|
86
|
+
input.context,
|
|
87
|
+
input.sessionId,
|
|
88
|
+
"tool_pairing_unsafe_over_context_limit",
|
|
89
|
+
true,
|
|
90
|
+
input.deps
|
|
91
|
+
);
|
|
92
|
+
const message = input.context.language === "en-US" ? "Context pressure is over the provider limit, but an unfinished tool pair makes compact unsafe. This provider request is blocked." : "\u5F53\u524D\u4E0A\u4E0B\u6587\u5DF2\u8D85\u8FC7 provider \u4E0A\u9650\uFF0C\u4F46\u5B58\u5728\u672A\u95ED\u5408 tool pair\uFF0C\u538B\u7F29\u4E0D\u5B89\u5168\u3002\u672C\u6B21 provider \u8BF7\u6C42\u5DF2\u963B\u65AD\u3002";
|
|
93
|
+
return { blocked: true, messages: budgeted, message };
|
|
94
|
+
}
|
|
95
|
+
return { blocked: false, messages: budgeted };
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
if (input.deps.runDeepCompact) {
|
|
99
|
+
const deep = await maybeRunDeepCompactBeforeProvider({
|
|
100
|
+
context: input.context,
|
|
101
|
+
sessionId: input.sessionId,
|
|
102
|
+
runtime: input.runtime,
|
|
103
|
+
trigger: input.trigger,
|
|
104
|
+
gateway: input.context.modelGateway,
|
|
105
|
+
signal: input.context.activeAbortController?.signal,
|
|
106
|
+
deps: input.deps.runDeepCompact
|
|
107
|
+
});
|
|
108
|
+
if (!deep.ok) {
|
|
109
|
+
await recordCompactFailure(
|
|
110
|
+
input.context,
|
|
111
|
+
input.sessionId,
|
|
112
|
+
`deep_compact_failed:${deep.message}`,
|
|
113
|
+
true,
|
|
114
|
+
input.deps
|
|
115
|
+
);
|
|
116
|
+
return { blocked: true, messages: budgeted, message: deep.message };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const compacted = compactMessagesToFit(budgeted, {
|
|
120
|
+
maxChars: Math.max(1, triggerChars - COMPACT_SUMMARY_TARGET_RESERVE_CHARS),
|
|
121
|
+
preserveRecentMessages: MAX_CONTEXT_MESSAGES,
|
|
122
|
+
kind: "micro"
|
|
123
|
+
});
|
|
124
|
+
if (!compacted.changed || !compacted.boundary) {
|
|
125
|
+
return { blocked: false, messages: budgeted };
|
|
126
|
+
}
|
|
127
|
+
const projection = createCompactProjection(input.context, {
|
|
128
|
+
boundary: compacted.boundary,
|
|
129
|
+
originalMessages: budgeted,
|
|
130
|
+
compactedMessages: compacted.messages,
|
|
131
|
+
contextMaxChars,
|
|
132
|
+
triggerChars,
|
|
133
|
+
trigger: input.trigger,
|
|
134
|
+
pairingSafe: pairing.safe
|
|
135
|
+
});
|
|
136
|
+
const providerMessages = injectDeepCompactSummary(
|
|
137
|
+
injectCompactProjectionMessage(compacted.messages, projection),
|
|
138
|
+
input.context.cache.deepCompact
|
|
139
|
+
);
|
|
140
|
+
if (estimateModelMessageChars(providerMessages) > contextMaxChars) {
|
|
141
|
+
await recordCompactFailure(
|
|
142
|
+
input.context,
|
|
143
|
+
input.sessionId,
|
|
144
|
+
"post_compact_summary_over_context_limit",
|
|
145
|
+
true,
|
|
146
|
+
input.deps
|
|
147
|
+
);
|
|
148
|
+
const message = input.context.language === "en-US" ? "Context compact summary still exceeds the provider limit, so the request is blocked." : "\u4E0A\u4E0B\u6587\u538B\u7F29\u6458\u8981\u540E\u4ECD\u8D85\u8FC7 provider \u4E0A\u9650\uFF0C\u672C\u6B21\u8BF7\u6C42\u5DF2\u963B\u65AD\u3002";
|
|
149
|
+
return { blocked: true, messages: budgeted, message };
|
|
150
|
+
}
|
|
151
|
+
if (!inspectToolPairingSafety(providerMessages).safe) {
|
|
152
|
+
await recordCompactFailure(
|
|
153
|
+
input.context,
|
|
154
|
+
input.sessionId,
|
|
155
|
+
"post_compact_pairing_unsafe",
|
|
156
|
+
true,
|
|
157
|
+
input.deps
|
|
158
|
+
);
|
|
159
|
+
const message = input.context.language === "en-US" ? "Context compact produced an unsafe tool pairing boundary, so the provider request is blocked." : "\u4E0A\u4E0B\u6587\u538B\u7F29\u540E\u7684 tool pairing \u8FB9\u754C\u4E0D\u5B89\u5168\uFF0C\u672C\u6B21 provider \u8BF7\u6C42\u5DF2\u963B\u65AD\u3002";
|
|
160
|
+
return { blocked: true, messages: budgeted, message };
|
|
161
|
+
}
|
|
162
|
+
recordCompactBoundary(input.context, compacted.boundary);
|
|
163
|
+
input.context.cache.compactProjection = projection;
|
|
164
|
+
input.context.cache.compactFailure = void 0;
|
|
165
|
+
input.context.cache.compactCooldownUntil = void 0;
|
|
166
|
+
input.deps.refreshCacheFreshness(input.context);
|
|
167
|
+
input.context.pushTranscriptBlock?.(
|
|
168
|
+
createCompactBoundaryBlock(
|
|
169
|
+
projection.preCompactChars,
|
|
170
|
+
projection.postCompactChars,
|
|
171
|
+
input.context.language
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
await appendCompactProjectionEvents(input.context, input.sessionId, projection, input.deps);
|
|
175
|
+
return { blocked: false, messages: providerMessages };
|
|
176
|
+
} catch (error) {
|
|
177
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
178
|
+
await recordCompactFailure(input.context, input.sessionId, reason, true, input.deps);
|
|
179
|
+
const message = input.context.language === "en-US" ? "Context compact failed, so this provider request is blocked instead of continuing with partial context." : "\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF0C\u672C\u6B21 provider \u8BF7\u6C42\u5DF2\u963B\u65AD\uFF0C\u4E0D\u4F1A\u62FF\u534A\u622A\u4E0A\u4E0B\u6587\u7EE7\u7EED\u8FD0\u884C\u3002";
|
|
180
|
+
return { blocked: true, messages: budgeted, message };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function prepareMessagesForProviderWithToolResultBudget(messages, context, sessionId, deps) {
|
|
184
|
+
const budgeted = await applyToolResultBudgetToMessages(messages, {
|
|
185
|
+
projectPath: context.projectPath,
|
|
186
|
+
sessionId,
|
|
187
|
+
state: getToolResultBudgetState(context)
|
|
188
|
+
});
|
|
189
|
+
for (const record of budgeted.records) {
|
|
190
|
+
await deps.recordToolResultBudgetEvidence(context, sessionId, record);
|
|
191
|
+
}
|
|
192
|
+
return budgeted.messages;
|
|
193
|
+
}
|
|
194
|
+
function getToolResultBudgetState(context) {
|
|
195
|
+
context.toolResultBudgetState ??= { seenIds: /* @__PURE__ */ new Set(), replacements: /* @__PURE__ */ new Map() };
|
|
196
|
+
return context.toolResultBudgetState;
|
|
197
|
+
}
|
|
198
|
+
function recordCompactBoundary(context, boundary) {
|
|
199
|
+
context.cache.compacted = true;
|
|
200
|
+
context.cache.compactBoundaries.push(boundary);
|
|
201
|
+
if (context.cache.compactBoundaries.length > MAX_COMPACT_BOUNDARIES) {
|
|
202
|
+
context.cache.compactBoundaries.shift();
|
|
203
|
+
}
|
|
204
|
+
void context.compactOutputMemory?.();
|
|
205
|
+
}
|
|
206
|
+
function getAutoCompactBufferTokens(context, runtime) {
|
|
207
|
+
const route = getRoleRoute(context.config, runtime.role);
|
|
208
|
+
const contextWindowTokens = getContextWindowForModel(runtime.model, route);
|
|
209
|
+
if (contextWindowTokens >= HUGE_CONTEXT_WINDOW_TOKENS) {
|
|
210
|
+
return HUGE_CONTEXT_BUFFER_TOKENS;
|
|
211
|
+
}
|
|
212
|
+
if (contextWindowTokens >= LARGE_CONTEXT_WINDOW_TOKENS) {
|
|
213
|
+
return LARGE_CONTEXT_BUFFER_TOKENS;
|
|
214
|
+
}
|
|
215
|
+
return AUTOCOMPACT_BUFFER_TOKENS;
|
|
216
|
+
}
|
|
217
|
+
function getAutoCompactTriggerChars(context, runtime) {
|
|
218
|
+
const maxChars = getProviderContextMaxChars(context, runtime);
|
|
219
|
+
const bufferChars = getAutoCompactBufferTokens(context, runtime) * CONTEXT_CHARS_PER_TOKEN_ESTIMATE;
|
|
220
|
+
return Math.max(1, maxChars - bufferChars);
|
|
221
|
+
}
|
|
222
|
+
function inspectToolPairingSafety(messages) {
|
|
223
|
+
const pending = /* @__PURE__ */ new Set();
|
|
224
|
+
const seenResults = /* @__PURE__ */ new Set();
|
|
225
|
+
let orphan = 0;
|
|
226
|
+
let duplicate = 0;
|
|
227
|
+
for (const message of messages) {
|
|
228
|
+
if (message.role === "assistant") {
|
|
229
|
+
for (const toolCall of message.toolCalls ?? []) {
|
|
230
|
+
if (pending.has(toolCall.id)) {
|
|
231
|
+
duplicate += 1;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
pending.add(toolCall.id);
|
|
235
|
+
}
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (message.role === "tool") {
|
|
239
|
+
if (!pending.has(message.tool_call_id)) {
|
|
240
|
+
orphan += 1;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (seenResults.has(message.tool_call_id)) {
|
|
244
|
+
duplicate += 1;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
pending.delete(message.tool_call_id);
|
|
248
|
+
seenResults.add(message.tool_call_id);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
safe: pending.size === 0 && orphan === 0 && duplicate === 0,
|
|
253
|
+
pending: pending.size,
|
|
254
|
+
orphan,
|
|
255
|
+
duplicate
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function createCompactProjection(context, input) {
|
|
259
|
+
const preCompactChars = estimateModelMessageChars(input.originalMessages);
|
|
260
|
+
const postCompactChars = estimateModelMessageChars(input.compactedMessages);
|
|
261
|
+
const removedMessages = Math.max(
|
|
262
|
+
0,
|
|
263
|
+
input.originalMessages.length - input.compactedMessages.length
|
|
264
|
+
);
|
|
265
|
+
const activeAgents = context.agents.filter((agent) => agent.status === "running").slice(0, 5).map(
|
|
266
|
+
(agent) => `${agent.id}:${agent.status}:${sanitizeCompactSummaryText(context, agent.summary || agent.task, 80)}`
|
|
267
|
+
);
|
|
268
|
+
const activeWorkflows = context.backgroundTasks.filter((task) => task.kind === "job" || task.kind === "agent").filter((task) => task.status === "running").slice(0, 5).map(
|
|
269
|
+
(task) => `${task.kind}:${task.status}:${sanitizeCompactSummaryText(context, task.userVisibleSummary, 80)}`
|
|
270
|
+
);
|
|
271
|
+
const needsAttentionWorkflows = context.backgroundTasks.filter((task) => task.kind === "job" || task.kind === "agent").filter((task) => task.status === "paused" || task.status === "blocked").slice(0, 5).map(
|
|
272
|
+
(task) => `${task.kind}:${task.status}:${sanitizeCompactSummaryText(context, task.userVisibleSummary, 80)}`
|
|
273
|
+
);
|
|
274
|
+
const staleResumableWorkflows = context.backgroundTasks.filter((task) => task.kind === "job" || task.kind === "agent").filter((task) => task.status === "stale").slice(0, 5).map(
|
|
275
|
+
(task) => `${task.kind}:${task.status}:${sanitizeCompactSummaryText(context, task.userVisibleSummary, 80)}`
|
|
276
|
+
);
|
|
277
|
+
const pending = [
|
|
278
|
+
context.pendingLocalApproval ? "local approval pending" : "",
|
|
279
|
+
context.pendingNaturalCommand ? "natural command pending" : "",
|
|
280
|
+
context.pendingAutopilot ? "autopilot pending" : ""
|
|
281
|
+
].filter(Boolean);
|
|
282
|
+
const failureLearning = context.failureLearning.records.slice(0, 3).map(
|
|
283
|
+
(record) => `${record.id}:${sanitizeCompactSummaryText(context, record.failureSummary, 100)}`
|
|
284
|
+
);
|
|
285
|
+
const evidenceRefs = context.evidence.slice(0, 8).map((item) => item.id);
|
|
286
|
+
const files = [
|
|
287
|
+
.../* @__PURE__ */ new Set([
|
|
288
|
+
...context.recentlyMentionedFiles.slice(0, 8),
|
|
289
|
+
...context.tools.changedFiles.slice(0, 8),
|
|
290
|
+
...input.boundary.preservedFiles.slice(0, 8)
|
|
291
|
+
])
|
|
292
|
+
].map((file) => sanitizeCompactSummaryText(context, file, 120)).slice(0, 12);
|
|
293
|
+
const risks = [
|
|
294
|
+
removedMessages > 0 ? `${removedMessages} older provider messages replaced by summary` : "",
|
|
295
|
+
input.boundary.compactedToolResultIds.length > 0 ? `${input.boundary.compactedToolResultIds.length} older tool results removed as complete pairs` : ""
|
|
296
|
+
].filter(Boolean);
|
|
297
|
+
const summary = truncateDisplay(
|
|
298
|
+
[
|
|
299
|
+
"Linghun compact summary",
|
|
300
|
+
"scope provider-visible recent context projection",
|
|
301
|
+
`trigger ${input.trigger}`,
|
|
302
|
+
`user goal ${sanitizeCompactSummaryText(context, context.memory.lastHandoff?.goal ?? "current interactive coding task", 220)}`,
|
|
303
|
+
`current task ${sanitizeCompactSummaryText(context, context.tools.todos.find((todo) => todo.status !== "completed")?.content ?? "continue the latest user request", 220)}`,
|
|
304
|
+
`decisions ${context.routeDecisions.slice(0, 3).map(
|
|
305
|
+
(item) => `${item.role}:${item.selectedProvider || "paused"}/${item.selectedModel || "paused"}`
|
|
306
|
+
).join("; ") || "none recorded"}`,
|
|
307
|
+
`files or evidence refs ${[...files, ...evidenceRefs.map((id) => `evidence:${id}`)].join(", ") || "none"}`,
|
|
308
|
+
`active agents/workflows ${[...activeAgents, ...activeWorkflows].join("; ") || "none"}`,
|
|
309
|
+
`needs-attention agents/workflows ${needsAttentionWorkflows.join("; ") || "none"}`,
|
|
310
|
+
`stale resumable agents/workflows ${staleResumableWorkflows.join("; ") || "none"}`,
|
|
311
|
+
`pending permissions/tool calls ${pending.join("; ") || "none"}`,
|
|
312
|
+
`failure learning ${failureLearning.join("; ") || "none"}`,
|
|
313
|
+
"anti hallucination: do not claim compact failure as PASS evidence; preserve evidence-bound claims only",
|
|
314
|
+
`index/cache/memory freshness: index ${context.index.status}; cache freshness ${context.cache.lastFreshness?.changedKeys?.join(",") || "stable-or-unknown"}; memory ${context.memory.accepted.length} accepted`,
|
|
315
|
+
`discarded scope ${risks.join("; ") || "older provider-visible recent context summarized"}`,
|
|
316
|
+
`tool pairing safe ${input.pairingSafe ? "yes" : "no"}`
|
|
317
|
+
].join("\n"),
|
|
318
|
+
COMPACT_SUMMARY_MAX_CHARS
|
|
319
|
+
);
|
|
320
|
+
return {
|
|
321
|
+
boundaryId: input.boundary.id,
|
|
322
|
+
createdAt: input.boundary.createdAt,
|
|
323
|
+
summary,
|
|
324
|
+
pressureRatio: Number((preCompactChars / Math.max(1, input.contextMaxChars)).toFixed(3)),
|
|
325
|
+
preCompactChars,
|
|
326
|
+
postCompactChars,
|
|
327
|
+
discardedRange: risks.join("; ") || "older provider-visible recent context summarized",
|
|
328
|
+
toolPairingSafe: input.pairingSafe,
|
|
329
|
+
risks,
|
|
330
|
+
evidenceRefs
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function sanitizeCompactSummaryText(context, value, maxChars) {
|
|
334
|
+
const singleLine = value.replace(/\s+/g, " ");
|
|
335
|
+
const withoutSecrets = sanitizeDiagnosticText(redactCommonSecrets(singleLine));
|
|
336
|
+
return truncateDisplay(sanitizeDisplayPaths(withoutSecrets, context.projectPath), maxChars);
|
|
337
|
+
}
|
|
338
|
+
function injectCompactProjectionMessage(messages, projection) {
|
|
339
|
+
const summaryMessage = {
|
|
340
|
+
role: "user",
|
|
341
|
+
content: `[Context compact boundary ${projection.boundaryId}]
|
|
342
|
+
${projection.summary}`
|
|
343
|
+
};
|
|
344
|
+
if (messages[0]?.role === "system") {
|
|
345
|
+
return [messages[0], summaryMessage, ...messages.slice(1)];
|
|
346
|
+
}
|
|
347
|
+
return [summaryMessage, ...messages];
|
|
348
|
+
}
|
|
349
|
+
async function appendCompactProjectionEvents(context, sessionId, projection, deps) {
|
|
350
|
+
await deps.appendSystemEvent(
|
|
351
|
+
context,
|
|
352
|
+
sessionId,
|
|
353
|
+
`${COMPACT_PROJECTION_EVENT_PREFIX}${JSON.stringify(projection)}`,
|
|
354
|
+
"info"
|
|
355
|
+
);
|
|
356
|
+
const evidence = createEvidenceRecord(
|
|
357
|
+
"user_provided",
|
|
358
|
+
`compact boundary ${projection.boundaryId}; scope provider-visible recent context projection; pressure ${projection.pressureRatio}; tool pairing safe ${projection.toolPairingSafe ? "yes" : "no"}`,
|
|
359
|
+
`compact:${projection.boundaryId}`,
|
|
360
|
+
["context_compact_boundary"]
|
|
361
|
+
);
|
|
362
|
+
rememberEvidence(context, evidence);
|
|
363
|
+
await context.store.appendEvent(sessionId, { type: "evidence_record", ...evidence });
|
|
364
|
+
}
|
|
365
|
+
async function recordCompactFailure(context, sessionId, reason, blocked, deps) {
|
|
366
|
+
const cooldownUntilMs = Date.now() + COMPACT_FAILURE_COOLDOWN_MS;
|
|
367
|
+
context.cache.compactCooldownUntil = cooldownUntilMs;
|
|
368
|
+
context.cache.compactFailure = {
|
|
369
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
370
|
+
reason: sanitizeCompactSummaryText(context, reason, 220),
|
|
371
|
+
blocked,
|
|
372
|
+
cooldownUntil: new Date(cooldownUntilMs).toISOString()
|
|
373
|
+
};
|
|
374
|
+
await deps.appendSystemEvent(
|
|
375
|
+
context,
|
|
376
|
+
sessionId,
|
|
377
|
+
`context compact failed: blocked ${blocked ? "yes" : "no"}; reason ${context.cache.compactFailure.reason}; cooldown until ${context.cache.compactFailure.cooldownUntil}`,
|
|
378
|
+
"warning"
|
|
379
|
+
);
|
|
380
|
+
await deps.captureFailureLearning(context, sessionId, {
|
|
381
|
+
category: "resource_cap",
|
|
382
|
+
failureSummary: "context compact failed before provider request",
|
|
383
|
+
rootCauseGuess: context.cache.compactFailure.reason,
|
|
384
|
+
avoidNextTime: "Do not continue with partial context after compact failure; retry after cooldown or reduce context pressure",
|
|
385
|
+
sourceRef: "system_event:context_compact_failed",
|
|
386
|
+
relatedTarget: "context compact",
|
|
387
|
+
severity: "medium"
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function getProviderContextMaxChars(context, runtime) {
|
|
391
|
+
const route = getRoleRoute(context.config, runtime.role);
|
|
392
|
+
const contextWindow = getContextWindowForModel(runtime.model, route);
|
|
393
|
+
const maxInputTokens = route.maxInputTokens ?? Math.max(
|
|
394
|
+
1,
|
|
395
|
+
contextWindow - (route.maxOutputTokens ?? context.config.providers[runtime.provider]?.maxOutputTokens ?? CONTEXT_INPUT_HEADROOM_TOKENS)
|
|
396
|
+
);
|
|
397
|
+
return Math.max(1, maxInputTokens * CONTEXT_CHARS_PER_TOKEN_ESTIMATE);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export {
|
|
401
|
+
prepareMessagesForProviderPreflight,
|
|
402
|
+
recordCompactBoundary,
|
|
403
|
+
getAutoCompactTriggerChars,
|
|
404
|
+
inspectToolPairingSafety,
|
|
405
|
+
sanitizeCompactSummaryText,
|
|
406
|
+
getProviderContextMaxChars
|
|
407
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
feishuBridgeAdapter,
|
|
3
|
+
feishuReceiveMessageToBridgeEvent
|
|
4
|
+
} from "./chunk-CFXB5SE5.js";
|
|
5
|
+
|
|
6
|
+
// src/feishu-long-connection-runtime.ts
|
|
7
|
+
import * as Lark from "@larksuiteoapi/node-sdk";
|
|
8
|
+
async function startFeishuLongConnection(options) {
|
|
9
|
+
if (!options.appId) throw new Error("Feishu long connection missing appId");
|
|
10
|
+
if (!options.appSecret) throw new Error("Feishu long connection missing appSecret");
|
|
11
|
+
const wsClient = new Lark.WSClient({
|
|
12
|
+
appId: options.appId,
|
|
13
|
+
appSecret: options.appSecret,
|
|
14
|
+
loggerLevel: Lark.LoggerLevel.error
|
|
15
|
+
});
|
|
16
|
+
const onMessage = async (data) => {
|
|
17
|
+
const event = feishuReceiveMessageToBridgeEvent(data, options.nowMs?.() ?? Date.now());
|
|
18
|
+
await options.onMessage(feishuBridgeAdapter(event));
|
|
19
|
+
};
|
|
20
|
+
const dispatcher = new Lark.EventDispatcher({}).register({
|
|
21
|
+
"im.message.receive_v1": onMessage
|
|
22
|
+
});
|
|
23
|
+
await wsClient.start({ eventDispatcher: dispatcher });
|
|
24
|
+
let closed = false;
|
|
25
|
+
let closePromise;
|
|
26
|
+
return {
|
|
27
|
+
close: async () => {
|
|
28
|
+
if (closed) {
|
|
29
|
+
await closePromise;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
closed = true;
|
|
33
|
+
dispatcher.handles.delete("im.message.receive_v1");
|
|
34
|
+
try {
|
|
35
|
+
wsClient.close({ force: true });
|
|
36
|
+
closePromise = Promise.resolve();
|
|
37
|
+
} catch (error) {
|
|
38
|
+
closePromise = Promise.reject(error);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
await closePromise;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
startFeishuLongConnection
|
|
48
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatReasoningEffectiveState
|
|
3
|
+
} from "./chunk-3LT6OWQ2.js";
|
|
4
|
+
import {
|
|
5
|
+
getRoleRoute,
|
|
6
|
+
inferProviderForRouteModel
|
|
7
|
+
} from "./chunk-2YL5VKJ5.js";
|
|
8
|
+
import {
|
|
9
|
+
checkProviderCooldown,
|
|
10
|
+
formatCooldownMessage
|
|
11
|
+
} from "./chunk-EBACIBJP.js";
|
|
12
|
+
import {
|
|
13
|
+
classifyProviderFailure,
|
|
14
|
+
formatProviderFallbackAttemptSummary
|
|
15
|
+
} from "./chunk-OZMX3E35.js";
|
|
16
|
+
import {
|
|
17
|
+
writeLine
|
|
18
|
+
} from "./chunk-OMZYPQVA.js";
|
|
19
|
+
|
|
20
|
+
// src/provider-loop-runtime.ts
|
|
21
|
+
import { randomUUID } from "crypto";
|
|
22
|
+
import { resolveEffectiveEndpointProfile } from "@linghun/providers";
|
|
23
|
+
function getProviderErrorCode(error) {
|
|
24
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "PROVIDER_ERROR";
|
|
25
|
+
}
|
|
26
|
+
function shouldAttemptRuntimeFallback(kind) {
|
|
27
|
+
return kind === "rate_limit" || kind === "quota_or_balance_exhausted" || kind === "gateway" || kind === "transit" || kind === "timeout";
|
|
28
|
+
}
|
|
29
|
+
function createRuntimeForFallbackModel(context, baseRuntime, fallbackModel) {
|
|
30
|
+
if (!fallbackModel || fallbackModel === baseRuntime.model) return void 0;
|
|
31
|
+
const provider = inferProviderForRouteModel(fallbackModel, context.config);
|
|
32
|
+
const providerConfig = context.config.providers[provider];
|
|
33
|
+
if (!providerConfig) return void 0;
|
|
34
|
+
const rawEndpointProfile = providerConfig.endpointProfile ?? "chat_completions";
|
|
35
|
+
const endpointProfile = resolveEffectiveEndpointProfile({
|
|
36
|
+
requestEndpointProfile: void 0,
|
|
37
|
+
configEndpointProfile: rawEndpointProfile,
|
|
38
|
+
configBaseUrl: providerConfig.baseUrl,
|
|
39
|
+
configModel: providerConfig.model,
|
|
40
|
+
requestModel: fallbackModel
|
|
41
|
+
}).endpointProfile;
|
|
42
|
+
const compatibilityProfile = providerConfig.compatibilityProfile ?? (providerConfig.type === "deepseek" ? "deepseek" : "strict_openai_compatible");
|
|
43
|
+
const reasoningLevel = providerConfig.reasoningLevel;
|
|
44
|
+
const reasoningSent = Boolean(
|
|
45
|
+
reasoningLevel && (endpointProfile === "responses" || compatibilityProfile === "permissive_openai_compatible" || endpointProfile === "anthropic_messages")
|
|
46
|
+
);
|
|
47
|
+
return {
|
|
48
|
+
role: baseRuntime.role,
|
|
49
|
+
provider,
|
|
50
|
+
model: fallbackModel,
|
|
51
|
+
endpointProfile,
|
|
52
|
+
reasoningLevel,
|
|
53
|
+
reasoningStatus: formatReasoningEffectiveState(reasoningLevel, reasoningSent),
|
|
54
|
+
reasoningSent
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function resolveRuntimeFallback(context, runtime, error) {
|
|
58
|
+
const kind = classifyProviderFailure(error);
|
|
59
|
+
if (!shouldAttemptRuntimeFallback(kind)) return void 0;
|
|
60
|
+
const route = getRoleRoute(context.config, runtime.role);
|
|
61
|
+
for (const fallbackModel of route.fallbackModels) {
|
|
62
|
+
const fallbackRuntime = createRuntimeForFallbackModel(context, runtime, fallbackModel);
|
|
63
|
+
if (!fallbackRuntime) continue;
|
|
64
|
+
if (fallbackRuntime.provider === runtime.provider && fallbackRuntime.model === runtime.model) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
return { runtime: fallbackRuntime, kind, code: getProviderErrorCode(error) };
|
|
68
|
+
}
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
async function recordProviderFallbackAttempt(context, sessionId, input) {
|
|
72
|
+
const summary = formatProviderFallbackAttemptSummary(
|
|
73
|
+
{
|
|
74
|
+
fromProvider: input.from.provider,
|
|
75
|
+
fromModel: input.from.model,
|
|
76
|
+
toProvider: input.to.provider,
|
|
77
|
+
toModel: input.to.model,
|
|
78
|
+
reasonKind: input.kind
|
|
79
|
+
},
|
|
80
|
+
context.language
|
|
81
|
+
);
|
|
82
|
+
context.lastProviderFallbackAttempt = {
|
|
83
|
+
fromProvider: input.from.provider,
|
|
84
|
+
fromModel: input.from.model,
|
|
85
|
+
toProvider: input.to.provider,
|
|
86
|
+
toModel: input.to.model,
|
|
87
|
+
reasonKind: input.kind,
|
|
88
|
+
reasonCode: input.code,
|
|
89
|
+
status: input.status,
|
|
90
|
+
summary,
|
|
91
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
92
|
+
};
|
|
93
|
+
const decision = context.routeDecisions.find(
|
|
94
|
+
(item) => item.role === input.from.role && item.selectedModel === input.from.model
|
|
95
|
+
);
|
|
96
|
+
if (decision) {
|
|
97
|
+
decision.fallbackUsed = true;
|
|
98
|
+
} else {
|
|
99
|
+
context.routeDecisions.unshift({
|
|
100
|
+
id: `route-${randomUUID().slice(0, 8)}`,
|
|
101
|
+
triggerReason: "provider runtime fallback",
|
|
102
|
+
role: input.from.role,
|
|
103
|
+
selectedProvider: input.to.provider,
|
|
104
|
+
selectedModel: input.to.model,
|
|
105
|
+
fallbackCandidates: [input.to.model],
|
|
106
|
+
requiredCapabilities: [],
|
|
107
|
+
stopConditions: [],
|
|
108
|
+
repairSuggestions: [],
|
|
109
|
+
fallbackUsed: true,
|
|
110
|
+
budgetStop: false,
|
|
111
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
await context.store.appendEvent(sessionId, {
|
|
115
|
+
type: "system_event",
|
|
116
|
+
id: randomUUID(),
|
|
117
|
+
level: input.status === "succeeded" ? "info" : "warning",
|
|
118
|
+
message: `provider fallback attempt: from ${input.from.provider}/${input.from.model}; to ${input.to.provider}/${input.to.model}; reason ${input.kind}; code ${input.code}; status ${input.status}`,
|
|
119
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function checkAndWriteProviderCooldown(context, runtime, output) {
|
|
123
|
+
const cooldownCheck = checkProviderCooldown(
|
|
124
|
+
context.providerBreaker,
|
|
125
|
+
runtime.provider,
|
|
126
|
+
runtime.model
|
|
127
|
+
);
|
|
128
|
+
if (!cooldownCheck.blocked) return false;
|
|
129
|
+
writeLine(
|
|
130
|
+
output,
|
|
131
|
+
formatCooldownMessage(
|
|
132
|
+
runtime.provider,
|
|
133
|
+
runtime.model,
|
|
134
|
+
cooldownCheck.remainingMs,
|
|
135
|
+
context.language
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
resolveRuntimeFallback,
|
|
143
|
+
recordProviderFallbackAttempt,
|
|
144
|
+
checkAndWriteProviderCooldown
|
|
145
|
+
};
|