@michengai/dsh-btw 1.3.11 → 1.3.12
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/CHANGELOG.md +5 -0
- package/CHANGELOG.zh-CN.md +5 -0
- package/lib/client.js +103 -2
- package/lib/index.js +105 -10
- package/lib/types/locales/zh.d.ts +2 -0
- package/lib/types/server/jobs.d.ts +4 -3
- package/lib/types/shared.d.ts +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.12] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
- **Seamless recovery for long-running deep-thinking side questions**: Fixes an issue where front-end connection timeouts on requests taking longer than 5 minutes (300 seconds) would cause the side-ask bubble to error and discard the answer. When a long HTTP connection times out, the server continues executing and preserves the completed result, allowing the front end to automatically reconnect and retrieve the full answer seamlessly (#27).
|
|
6
|
+
- **Cleaner conversation history and command view isolation**: Fully registers internal status queries in the chat command view filter, preventing redundant command placeholder cards during side-question recovery and keeping the conversation history clean and uncluttered.
|
|
7
|
+
|
|
3
8
|
## [1.3.11] - 2026-11-14
|
|
4
9
|
|
|
5
10
|
### Host Compatibility
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## [1.3.12] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
- **长耗时深度思考旁问断线自愈恢复**:修复在模型深度思考或长篇回答超过 5 分钟(300 秒)时前端连接超时导致气泡意外报错中断的问题。当网络长连接断开时,服务端旁问任务将持续执行并保留最终结果,前端自动接力取回完整回答,不再丢失答案(#27)。
|
|
6
|
+
- **优化旁问命令与会话历史整洁度**:将内部状态查询命令彻底纳入会话消息视图过滤,防止在旁问恢复期间出现冗余命令卡片,保持主会话记录清爽干净。
|
|
7
|
+
|
|
3
8
|
## [1.3.11] - 2026-11-14
|
|
4
9
|
|
|
5
10
|
### 宿主兼容
|
package/lib/client.js
CHANGED
|
@@ -506,6 +506,7 @@ var zh = {
|
|
|
506
506
|
"command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\uFF0C\u4E0D\u6267\u884C\u5DE5\u5177",
|
|
507
507
|
"command.hint": "\u65C1\u95EE\u5185\u5BB9",
|
|
508
508
|
"command.internalClose": "\u5173\u95ED\u5E76\u6E05\u7406\u6307\u5B9A BTW \u8BF7\u6C42",
|
|
509
|
+
"command.internalQuery": "\u67E5\u8BE2 BTW \u65C1\u95EE\u4EFB\u52A1\u72B6\u6001",
|
|
509
510
|
"command.internalRun": "BTW \u6C14\u6CE1\u5185\u90E8\u8BF7\u6C42",
|
|
510
511
|
"command.label": "\u65C1\u95EE",
|
|
511
512
|
"error.attachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u56FE\u7247\u548C\u6587\u4EF6\u4ECD\u4FDD\u7559\u5728\u8F93\u5165\u6846\u4E2D\u3002",
|
|
@@ -524,6 +525,7 @@ var zh = {
|
|
|
524
525
|
"error.incomplete": "\u65C1\u95EE\u672A\u5B8C\u6210\uFF08{reason}\uFF09\u3002{detail}",
|
|
525
526
|
"error.length": `\u65C1\u95EE\u6700\u591A\u652F\u6301 ${MAX_QUESTION_LENGTH} \u4E2A\u5B57\u7B26\u3002`,
|
|
526
527
|
"error.noText": "\u6A21\u578B\u672A\u8FD4\u56DE\u6587\u5B57\u56DE\u7B54\u3002",
|
|
528
|
+
"error.network": "\u7F51\u7EDC\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u65E0\u6CD5\u53D6\u56DE\u65C1\u95EE\u7ED3\u679C\u3002",
|
|
527
529
|
"error.provider": "\u5F53\u524D fork provider \u4E0D\u652F\u6301\u7EE7\u627F\u4E0A\u4E0B\u6587\u5E76\u7981\u7528\u5DE5\u5177\uFF0C\u65C1\u95EE\u672A\u542F\u52A8\u3002",
|
|
528
530
|
"error.quotesTotalLength": `\u5F15\u7528\u5408\u8BA1\u957F\u5EA6\u8D85\u51FA\u4E0A\u9650\uFF08\u6700\u591A ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("zh-CN")} \u5B57\u7B26\uFF09\u3002`,
|
|
529
531
|
"error.reference": `\u8BF7\u9009\u62E9 1\u2013${MAX_REFERENCE_LENGTH} \u4E2A\u5B57\u7B26\u7684\u6B63\u6587\uFF08\u542B\u7A7A\u767D\uFF0C\u90E8\u5206\u7B26\u53F7\u8BA1\u4E3A\u591A\u4E2A\u5B57\u7B26\uFF09\u3002`,
|
|
@@ -595,6 +597,7 @@ var en = {
|
|
|
595
597
|
"command.description": "Answer from current context without running tools",
|
|
596
598
|
"command.hint": "Side question",
|
|
597
599
|
"command.internalClose": "Close and clean up the specified BTW request",
|
|
600
|
+
"command.internalQuery": "Query BTW side job status",
|
|
598
601
|
"command.internalRun": "Internal BTW bubble request",
|
|
599
602
|
"command.label": "Side question",
|
|
600
603
|
"error.attachments": "Side questions accept text only. Your images and files remain in the input.",
|
|
@@ -613,6 +616,7 @@ var en = {
|
|
|
613
616
|
"error.incomplete": "The side question did not complete ({reason}).{detail}",
|
|
614
617
|
"error.length": `Side questions are limited to ${MAX_QUESTION_LENGTH.toLocaleString("en-US")} characters.`,
|
|
615
618
|
"error.noText": "The model returned no text.",
|
|
619
|
+
"error.network": "Network connection lost; failed to retrieve side-ask result.",
|
|
616
620
|
"error.provider": "The fork provider cannot inherit context with tools disabled. The side question was not started.",
|
|
617
621
|
"error.quotesTotalLength": `Total length of quoted selections exceeds the limit (max ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("en-US")} characters).`,
|
|
618
622
|
"error.reference": `Select 1\u2013${MAX_REFERENCE_LENGTH.toLocaleString("en-US")} characters of message text, including whitespace (some symbols count as multiple characters).`,
|
|
@@ -684,6 +688,7 @@ var ja = {
|
|
|
684
688
|
"command.description": "\u73FE\u5728\u306E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u57FA\u3065\u3044\u3066\u56DE\u7B54\uFF08\u30C4\u30FC\u30EB\u306F\u5B9F\u884C\u3057\u307E\u305B\u3093\uFF09",
|
|
685
689
|
"command.hint": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306E\u5185\u5BB9",
|
|
686
690
|
"command.internalClose": "\u6307\u5B9A\u3055\u308C\u305F BTW \u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u7D42\u4E86\u3057\u3066\u30AF\u30EA\u30FC\u30F3\u30A2\u30C3\u30D7",
|
|
691
|
+
"command.internalQuery": "BTW \u30B5\u30A4\u30C9\u8CEA\u554F\u30BF\u30B9\u30AF\u306E\u72B6\u614B\u3092\u7167\u4F1A",
|
|
687
692
|
"command.internalRun": "BTW \u30D0\u30D6\u30EB\u5185\u90E8\u30EA\u30AF\u30A8\u30B9\u30C8",
|
|
688
693
|
"command.label": "\u30B5\u30A4\u30C9\u8CEA\u554F",
|
|
689
694
|
"error.attachments": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u30C6\u30AD\u30B9\u30C8\u306E\u307F\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u3059\u3002\u753B\u50CF\u3084\u30D5\u30A1\u30A4\u30EB\u306F\u5165\u529B\u6B04\u306B\u6B8B\u308A\u307E\u3059\u3002",
|
|
@@ -702,6 +707,7 @@ var ja = {
|
|
|
702
707
|
"error.incomplete": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u5B8C\u4E86\u3057\u307E\u305B\u3093\u3067\u3057\u305F\uFF08{reason}\uFF09\u3002{detail}",
|
|
703
708
|
"error.length": `\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u6700\u5927 ${MAX_QUESTION_LENGTH.toLocaleString("ja-JP")} \u6587\u5B57\u307E\u3067\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u3059\u3002`,
|
|
704
709
|
"error.noText": "\u30E2\u30C7\u30EB\u304B\u3089\u30C6\u30AD\u30B9\u30C8\u306E\u56DE\u7B54\u304C\u8FD4\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
710
|
+
"error.network": "\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u304C\u5207\u65AD\u3055\u308C\u305F\u305F\u3081\u3001\u30B5\u30A4\u30C9\u8CEA\u554F\u306E\u7D50\u679C\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
705
711
|
"error.provider": "\u73FE\u5728\u306E fork \u30D7\u30ED\u30D0\u30A4\u30C0\u30FC\u306F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u7D99\u627F\u3068\u30C4\u30FC\u30EB\u7121\u52B9\u5316\u3092\u540C\u6642\u306B\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
|
|
706
712
|
"error.quotesTotalLength": `\u5F15\u7528\u306E\u5408\u8A08\u6587\u5B57\u6570\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\uFF08\u6700\u5927 ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("ja-JP")} \u6587\u5B57\uFF09\u3002`,
|
|
707
713
|
"error.reference": `1\u301C${MAX_REFERENCE_LENGTH.toLocaleString("ja-JP")}\u6587\u5B57\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7A7A\u767D\u3092\u542B\u307F\u3001\u4E00\u90E8\u306E\u8A18\u53F7\u306F\u8907\u6570\u6587\u5B57\u3068\u3057\u3066\u30AB\u30A6\u30F3\u30C8\u3055\u308C\u307E\u3059\uFF09\u3002`,
|
|
@@ -773,6 +779,7 @@ var es = {
|
|
|
773
779
|
"command.description": "Responde seg\xFAn el contexto actual sin ejecutar herramientas",
|
|
774
780
|
"command.hint": "Pregunta secundaria",
|
|
775
781
|
"command.internalClose": "Cerrar y limpiar la solicitud BTW especificada",
|
|
782
|
+
"command.internalQuery": "Consultar estado de la tarea de pregunta secundaria BTW",
|
|
776
783
|
"command.internalRun": "Solicitud interna de burbuja BTW",
|
|
777
784
|
"command.label": "Pregunta secundaria",
|
|
778
785
|
"error.attachments": "Las preguntas secundarias solo aceptan texto. Las im\xE1genes y archivos permanecen en la entrada.",
|
|
@@ -791,6 +798,7 @@ var es = {
|
|
|
791
798
|
"error.incomplete": "La pregunta secundaria no se complet\xF3 ({reason}).{detail}",
|
|
792
799
|
"error.length": `Las preguntas secundarias admiten un m\xE1ximo de ${MAX_QUESTION_LENGTH.toLocaleString("es-ES")} caracteres.`,
|
|
793
800
|
"error.noText": "El modelo no devolvi\xF3 ninguna respuesta de texto.",
|
|
801
|
+
"error.network": "Conexi\xF3n de red perdida; no se pudo recuperar el resultado de la pregunta secundaria.",
|
|
794
802
|
"error.provider": "El proveedor de bifurcaci\xF3n no admite heredar contexto con herramientas deshabilitadas. La pregunta secundaria no se inici\xF3.",
|
|
795
803
|
"error.quotesTotalLength": `La longitud total de las citas supera el l\xEDmite (m\xE1ximo ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("es-ES")} caracteres).`,
|
|
796
804
|
"error.reference": `Seleccione entre 1 y ${MAX_REFERENCE_LENGTH.toLocaleString("es-ES")} caracteres de texto, incluidos espacios en blanco (algunos s\xEDmbolos cuentan como varios caracteres).`,
|
|
@@ -862,6 +870,7 @@ var fr = {
|
|
|
862
870
|
"command.description": "R\xE9pondre \xE0 partir du contexte actuel sans ex\xE9cuter d'outils",
|
|
863
871
|
"command.hint": "Question secondaire",
|
|
864
872
|
"command.internalClose": "Fermer et nettoyer la requ\xEAte BTW sp\xE9cifi\xE9e",
|
|
873
|
+
"command.internalQuery": "Interroger l'\xE9tat de la t\xE2che de question secondaire BTW",
|
|
865
874
|
"command.internalRun": "Requ\xEAte interne de bulle BTW",
|
|
866
875
|
"command.label": "Question secondaire",
|
|
867
876
|
"error.attachments": "Les questions secondaires n'acceptent que du texte. Les images et fichiers restent dans la zone de saisie.",
|
|
@@ -880,6 +889,7 @@ var fr = {
|
|
|
880
889
|
"error.incomplete": "La question secondaire ne s'est pas termin\xE9e ({reason}).{detail}",
|
|
881
890
|
"error.length": `Les questions secondaires sont limit\xE9es \xE0 ${MAX_QUESTION_LENGTH.toLocaleString("fr-FR")} caract\xE8res.`,
|
|
882
891
|
"error.noText": "Le mod\xE8le n'a renvoy\xE9 aucune r\xE9ponse textuelle.",
|
|
892
|
+
"error.network": "Connexion r\xE9seau perdue ; \xE9chec de la r\xE9cup\xE9ration du r\xE9sultat de la question secondaire.",
|
|
883
893
|
"error.provider": "Le fournisseur de fork ne prend pas en charge l'h\xE9ritage du contexte avec outils d\xE9sactiv\xE9s. La question secondaire n'a pas \xE9t\xE9 lanc\xE9e.",
|
|
884
894
|
"error.quotesTotalLength": `La longueur totale des citations d\xE9passe la limite (maximum ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("fr-FR")} caract\xE8res).`,
|
|
885
895
|
"error.reference": `S\xE9lectionnez entre 1 et ${MAX_REFERENCE_LENGTH.toLocaleString("fr-FR")} caract\xE8res de texte, espaces compris (certains symboles comptent pour plusieurs caract\xE8res).`,
|
|
@@ -951,6 +961,7 @@ var de = {
|
|
|
951
961
|
"command.description": "Aus aktuellem Kontext antworten, ohne Tools auszuf\xFChren",
|
|
952
962
|
"command.hint": "Nebenfrage",
|
|
953
963
|
"command.internalClose": "Angegebene BTW-Anfrage schlie\xDFen und bereinigen",
|
|
964
|
+
"command.internalQuery": "Status des BTW-Nebenfragenauftrags abfragen",
|
|
954
965
|
"command.internalRun": "Interne BTW-Sprechblasenanfrage",
|
|
955
966
|
"command.label": "Nebenfrage",
|
|
956
967
|
"error.attachments": "Nebenfragen akzeptieren nur Text. Bilder und Dateien verbleiben im Eingabefeld.",
|
|
@@ -969,6 +980,7 @@ var de = {
|
|
|
969
980
|
"error.incomplete": "Die Nebenfrage wurde nicht abgeschlossen ({reason}).{detail}",
|
|
970
981
|
"error.length": `Nebenfragen sind auf maximal ${MAX_QUESTION_LENGTH.toLocaleString("de-DE")} Zeichen begrenzt.`,
|
|
971
982
|
"error.noText": "Das Modell hat keine Textantwort zur\xFCckgegeben.",
|
|
983
|
+
"error.network": "Netzwerkverbindung unterbrochen; Ergebnis der Nebenfrage konnte nicht abgerufen werden.",
|
|
972
984
|
"error.provider": "Der Fork-Provider unterst\xFCtzt die Vererbung des Kontexts bei deaktivierten Tools nicht. Die Nebenfrage wurde nicht gestartet.",
|
|
973
985
|
"error.quotesTotalLength": `Die Gesamtl\xE4nge der Zitate \xFCberschreitet das Limit (maximal ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("de-DE")} Zeichen).`,
|
|
974
986
|
"error.reference": `W\xE4hlen Sie 1 bis ${MAX_REFERENCE_LENGTH.toLocaleString("de-DE")} Textzeichen aus, einschlie\xDFlich Leerzeichen (einige Symbole z\xE4hlen als mehrere Zeichen).`,
|
|
@@ -1040,6 +1052,7 @@ var ru = {
|
|
|
1040
1052
|
"command.description": "\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C \u043D\u0430 \u043E\u0441\u043D\u043E\u0432\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430 \u0431\u0435\u0437 \u0432\u044B\u0437\u043E\u0432\u0430 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u0432",
|
|
1041
1053
|
"command.hint": "\u0422\u0435\u043A\u0441\u0442 \u043F\u043E\u0431\u043E\u0447\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430",
|
|
1042
1054
|
"command.internalClose": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0438 \u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u0437\u0430\u043F\u0440\u043E\u0441 BTW",
|
|
1055
|
+
"command.internalQuery": "\u0417\u0430\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u0434\u0430\u0447\u0438 \u043F\u043E\u043F\u0443\u0442\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430 BTW",
|
|
1043
1056
|
"command.internalRun": "\u0412\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u0438\u0439 \u0437\u0430\u043F\u0440\u043E\u0441 \u043F\u0443\u0437\u044B\u0440\u044F BTW",
|
|
1044
1057
|
"command.label": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441",
|
|
1045
1058
|
"error.attachments": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0435 \u0432\u043E\u043F\u0440\u043E\u0441\u044B \u043F\u0440\u0438\u043D\u0438\u043C\u0430\u044E\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0442\u0435\u043A\u0441\u0442. \u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u0438 \u0444\u0430\u0439\u043B\u044B \u043E\u0441\u0442\u0430\u043D\u0443\u0442\u0441\u044F \u0432 \u043F\u043E\u043B\u0435 \u0432\u0432\u043E\u0434\u0430.",
|
|
@@ -1058,6 +1071,7 @@ var ru = {
|
|
|
1058
1071
|
"error.incomplete": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D ({reason}).{detail}",
|
|
1059
1072
|
"error.length": `\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 ${MAX_QUESTION_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432.`,
|
|
1060
1073
|
"error.noText": "\u041C\u043E\u0434\u0435\u043B\u044C \u043D\u0435 \u0432\u0435\u0440\u043D\u0443\u043B\u0430 \u0442\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u043E\u0442\u0432\u0435\u0442.",
|
|
1074
|
+
"error.network": "\u0421\u0435\u0442\u0435\u0432\u043E\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 \u0440\u0430\u0437\u043E\u0440\u0432\u0430\u043D\u043E; \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u043F\u043E\u043F\u0443\u0442\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430.",
|
|
1061
1075
|
"error.provider": "\u0422\u0435\u043A\u0443\u0449\u0438\u0439 fork provider \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043D\u0430\u0441\u043B\u0435\u0434\u043E\u0432\u0430\u043D\u0438\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430 \u0441 \u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043D\u044B\u043C\u0438 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0430\u043C\u0438. \u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D.",
|
|
1062
1076
|
"error.quotesTotalLength": `\u041E\u0431\u0449\u0430\u044F \u0434\u043B\u0438\u043D\u0430 \u0446\u0438\u0442\u0430\u0442 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043B\u0438\u043C\u0438\u0442 (\u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432).`,
|
|
1063
1077
|
"error.reference": `\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442 1 \u0434\u043E ${MAX_REFERENCE_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432 \u0442\u0435\u043A\u0441\u0442\u0430, \u0432\u043A\u043B\u044E\u0447\u0430\u044F \u043F\u0440\u043E\u0431\u0435\u043B\u044B (\u043D\u0435\u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u0441\u0447\u0438\u0442\u0430\u044E\u0442\u0441\u044F \u0437\u0430 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E).`,
|
|
@@ -1129,6 +1143,7 @@ var pt = {
|
|
|
1129
1143
|
"command.description": "Responder com base no contexto atual sem executar ferramentas",
|
|
1130
1144
|
"command.hint": "Conte\xFAdo da pergunta secund\xE1ria",
|
|
1131
1145
|
"command.internalClose": "Fechar e limpar a solicita\xE7\xE3o BTW especificada",
|
|
1146
|
+
"command.internalQuery": "Consultar status da tarefa de pergunta secund\xE1ria BTW",
|
|
1132
1147
|
"command.internalRun": "Solicita\xE7\xE3o interna de bal\xE3o BTW",
|
|
1133
1148
|
"command.label": "Pergunta secund\xE1ria",
|
|
1134
1149
|
"error.attachments": "As perguntas secund\xE1rias aceitam apenas texto. As imagens e arquivos continuam no campo de entrada.",
|
|
@@ -1147,6 +1162,7 @@ var pt = {
|
|
|
1147
1162
|
"error.incomplete": "A pergunta secund\xE1ria n\xE3o foi conclu\xEDda ({reason}).{detail}",
|
|
1148
1163
|
"error.length": `As perguntas secund\xE1rias s\xE3o limitadas a ${MAX_QUESTION_LENGTH.toLocaleString("pt-BR")} caracteres.`,
|
|
1149
1164
|
"error.noText": "O modelo n\xE3o retornou nenhuma resposta em texto.",
|
|
1165
|
+
"error.network": "Conex\xE3o de rede perdida; falha ao recuperar o resultado da pergunta secund\xE1ria.",
|
|
1150
1166
|
"error.provider": "O provedor de fork n\xE3o suporta herdar o contexto com as ferramentas desativadas. A pergunta secund\xE1ria n\xE3o foi iniciada.",
|
|
1151
1167
|
"error.quotesTotalLength": `O comprimento total das cita\xE7\xF5es excede o limite (m\xE1ximo ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("pt-BR")} caracteres).`,
|
|
1152
1168
|
"error.reference": `Selecione de 1 a ${MAX_REFERENCE_LENGTH.toLocaleString("pt-BR")} caracteres de texto, incluindo espa\xE7os em branco (alguns s\xEDmbolos contam como m\xFAltiplos caracteres).`,
|
|
@@ -1232,6 +1248,10 @@ function normalizeLocale(value) {
|
|
|
1232
1248
|
// src/shared.ts
|
|
1233
1249
|
var RUN_COMMAND = "btw-run";
|
|
1234
1250
|
var CLOSE_COMMAND = "btw-close";
|
|
1251
|
+
var QUERY_COMMAND = "btw-query";
|
|
1252
|
+
var INTERNAL_COMMANDS = [RUN_COMMAND, CLOSE_COMMAND, QUERY_COMMAND];
|
|
1253
|
+
var JOB_ROUTE_PATH = "/api/michengai-btw/job";
|
|
1254
|
+
var DEFAULT_TIMEOUT_MS = 18e5;
|
|
1235
1255
|
|
|
1236
1256
|
// src/client/bubbles.ts
|
|
1237
1257
|
var MAX_BUBBLES_PER_SESSION = 20;
|
|
@@ -15763,8 +15783,89 @@ function apply(ctx) {
|
|
|
15763
15783
|
if (!response.value) throw new Error(t("error.backend"));
|
|
15764
15784
|
return { kind: response.value.result.kind, text: response.value.result.text ?? "" };
|
|
15765
15785
|
};
|
|
15786
|
+
const pollResult = async (session, id, signal) => {
|
|
15787
|
+
const startTime = Date.now();
|
|
15788
|
+
let delay = 50;
|
|
15789
|
+
let httpAvailable = typeof window !== "undefined" && typeof window.fetch === "function";
|
|
15790
|
+
let commandQueryAttempts = 0;
|
|
15791
|
+
let consecutiveFailures = 0;
|
|
15792
|
+
let firstFailureTime = 0;
|
|
15793
|
+
let lastError;
|
|
15794
|
+
while (!signal.aborted && Date.now() - startTime < DEFAULT_TIMEOUT_MS) {
|
|
15795
|
+
if (delay > 0) {
|
|
15796
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
15797
|
+
}
|
|
15798
|
+
delay = Math.min(delay < 1e3 ? 1e3 : delay + 1e3, 5e3);
|
|
15799
|
+
if (signal.aborted) break;
|
|
15800
|
+
let status;
|
|
15801
|
+
let transportSuccess = false;
|
|
15802
|
+
if (httpAvailable) {
|
|
15803
|
+
try {
|
|
15804
|
+
const resp = await window.fetch(`${JOB_ROUTE_PATH}?session=${encodeURIComponent(session)}&id=${encodeURIComponent(id)}`, { signal });
|
|
15805
|
+
if (resp.status === 404 || resp.status === 401 || resp.status === 403) {
|
|
15806
|
+
httpAvailable = false;
|
|
15807
|
+
} else if (resp.ok) {
|
|
15808
|
+
transportSuccess = true;
|
|
15809
|
+
status = await resp.json();
|
|
15810
|
+
} else {
|
|
15811
|
+
lastError = new Error(`HTTP ${resp.status}`);
|
|
15812
|
+
}
|
|
15813
|
+
} catch (err) {
|
|
15814
|
+
if (signal.aborted) break;
|
|
15815
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
15816
|
+
}
|
|
15817
|
+
}
|
|
15818
|
+
const shouldQueryViaCommand = !status && !signal.aborted && (!httpAvailable || commandQueryAttempts < 2);
|
|
15819
|
+
if (shouldQueryViaCommand) {
|
|
15820
|
+
try {
|
|
15821
|
+
if (httpAvailable) commandQueryAttempts++;
|
|
15822
|
+
const queryRes = await execute(session, `/${QUERY_COMMAND} ${id}`, signal);
|
|
15823
|
+
if (queryRes.kind === "success" && queryRes.text) {
|
|
15824
|
+
transportSuccess = true;
|
|
15825
|
+
status = JSON.parse(queryRes.text);
|
|
15826
|
+
}
|
|
15827
|
+
} catch (err) {
|
|
15828
|
+
if (signal.aborted) break;
|
|
15829
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
15830
|
+
}
|
|
15831
|
+
}
|
|
15832
|
+
if (transportSuccess) {
|
|
15833
|
+
consecutiveFailures = 0;
|
|
15834
|
+
firstFailureTime = 0;
|
|
15835
|
+
} else {
|
|
15836
|
+
consecutiveFailures++;
|
|
15837
|
+
if (firstFailureTime === 0) firstFailureTime = Date.now();
|
|
15838
|
+
if (consecutiveFailures >= 6 && Date.now() - firstFailureTime >= 6e4) {
|
|
15839
|
+
if (lastError && typeof console !== "undefined" && console.debug) {
|
|
15840
|
+
console.debug("[dsh-btw] side-ask polling failed due to network disruption:", lastError);
|
|
15841
|
+
}
|
|
15842
|
+
throw new Error(t("error.network"));
|
|
15843
|
+
}
|
|
15844
|
+
}
|
|
15845
|
+
if (status?.state === "done" && status.result) {
|
|
15846
|
+
return status.result;
|
|
15847
|
+
}
|
|
15848
|
+
if (status?.state === "not-found" && Date.now() - startTime > 1e4) {
|
|
15849
|
+
throw new Error(t("error.backend"));
|
|
15850
|
+
}
|
|
15851
|
+
}
|
|
15852
|
+
if (signal.aborted) throw new Error(t("error.cancelled"));
|
|
15853
|
+
if (lastError && typeof console !== "undefined" && console.debug) {
|
|
15854
|
+
console.debug("[dsh-btw] side-ask polling timeout, last error:", lastError);
|
|
15855
|
+
}
|
|
15856
|
+
throw new Error(t("error.timeout"));
|
|
15857
|
+
};
|
|
15858
|
+
const runWithRecovery = async (session, id, question, signal, reference) => {
|
|
15859
|
+
try {
|
|
15860
|
+
return await execute(session, `/${RUN_COMMAND} ${JSON.stringify({ id, question, reference, locale: normalizeLocale(t("locale.id")) })}`, signal);
|
|
15861
|
+
} catch (error) {
|
|
15862
|
+
if (signal.aborted) throw error;
|
|
15863
|
+
if (error instanceof SideRequestNotStartedError) throw error;
|
|
15864
|
+
return await pollResult(session, id, signal);
|
|
15865
|
+
}
|
|
15866
|
+
};
|
|
15766
15867
|
const store = new BubbleStore({
|
|
15767
|
-
run: (session, id, question, signal, reference) =>
|
|
15868
|
+
run: (session, id, question, signal, reference) => runWithRecovery(session, id, question, signal, reference),
|
|
15768
15869
|
close: (session, id) => execute(session, `/${CLOSE_COMMAND} ${id}`)
|
|
15769
15870
|
}, t);
|
|
15770
15871
|
const quoteStore = new QuoteStore();
|
|
@@ -15934,7 +16035,7 @@ function apply(ctx) {
|
|
|
15934
16035
|
return () => disposers.forEach((d) => d());
|
|
15935
16036
|
});
|
|
15936
16037
|
slots.inject("conversation.chat.commandview", () => {
|
|
15937
|
-
const off =
|
|
16038
|
+
const off = INTERNAL_COMMANDS.map((key) => slots.register({ name: "conversation.chat.commandview", key }, () => null));
|
|
15938
16039
|
return () => off.forEach((dispose) => dispose());
|
|
15939
16040
|
});
|
|
15940
16041
|
ctx.inject(["configForms"], (scope) => {
|
package/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var zh = {
|
|
|
30
30
|
"command.description": "\u6839\u636E\u5F53\u524D\u4E0A\u4E0B\u6587\u56DE\u7B54\uFF0C\u4E0D\u6267\u884C\u5DE5\u5177",
|
|
31
31
|
"command.hint": "\u65C1\u95EE\u5185\u5BB9",
|
|
32
32
|
"command.internalClose": "\u5173\u95ED\u5E76\u6E05\u7406\u6307\u5B9A BTW \u8BF7\u6C42",
|
|
33
|
+
"command.internalQuery": "\u67E5\u8BE2 BTW \u65C1\u95EE\u4EFB\u52A1\u72B6\u6001",
|
|
33
34
|
"command.internalRun": "BTW \u6C14\u6CE1\u5185\u90E8\u8BF7\u6C42",
|
|
34
35
|
"command.label": "\u65C1\u95EE",
|
|
35
36
|
"error.attachments": "\u65C1\u95EE\u53EA\u63A5\u53D7\u6587\u5B57\uFF0C\u56FE\u7247\u548C\u6587\u4EF6\u4ECD\u4FDD\u7559\u5728\u8F93\u5165\u6846\u4E2D\u3002",
|
|
@@ -48,6 +49,7 @@ var zh = {
|
|
|
48
49
|
"error.incomplete": "\u65C1\u95EE\u672A\u5B8C\u6210\uFF08{reason}\uFF09\u3002{detail}",
|
|
49
50
|
"error.length": `\u65C1\u95EE\u6700\u591A\u652F\u6301 ${MAX_QUESTION_LENGTH} \u4E2A\u5B57\u7B26\u3002`,
|
|
50
51
|
"error.noText": "\u6A21\u578B\u672A\u8FD4\u56DE\u6587\u5B57\u56DE\u7B54\u3002",
|
|
52
|
+
"error.network": "\u7F51\u7EDC\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u65E0\u6CD5\u53D6\u56DE\u65C1\u95EE\u7ED3\u679C\u3002",
|
|
51
53
|
"error.provider": "\u5F53\u524D fork provider \u4E0D\u652F\u6301\u7EE7\u627F\u4E0A\u4E0B\u6587\u5E76\u7981\u7528\u5DE5\u5177\uFF0C\u65C1\u95EE\u672A\u542F\u52A8\u3002",
|
|
52
54
|
"error.quotesTotalLength": `\u5F15\u7528\u5408\u8BA1\u957F\u5EA6\u8D85\u51FA\u4E0A\u9650\uFF08\u6700\u591A ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("zh-CN")} \u5B57\u7B26\uFF09\u3002`,
|
|
53
55
|
"error.reference": `\u8BF7\u9009\u62E9 1\u2013${MAX_REFERENCE_LENGTH} \u4E2A\u5B57\u7B26\u7684\u6B63\u6587\uFF08\u542B\u7A7A\u767D\uFF0C\u90E8\u5206\u7B26\u53F7\u8BA1\u4E3A\u591A\u4E2A\u5B57\u7B26\uFF09\u3002`,
|
|
@@ -119,6 +121,7 @@ var en = {
|
|
|
119
121
|
"command.description": "Answer from current context without running tools",
|
|
120
122
|
"command.hint": "Side question",
|
|
121
123
|
"command.internalClose": "Close and clean up the specified BTW request",
|
|
124
|
+
"command.internalQuery": "Query BTW side job status",
|
|
122
125
|
"command.internalRun": "Internal BTW bubble request",
|
|
123
126
|
"command.label": "Side question",
|
|
124
127
|
"error.attachments": "Side questions accept text only. Your images and files remain in the input.",
|
|
@@ -137,6 +140,7 @@ var en = {
|
|
|
137
140
|
"error.incomplete": "The side question did not complete ({reason}).{detail}",
|
|
138
141
|
"error.length": `Side questions are limited to ${MAX_QUESTION_LENGTH.toLocaleString("en-US")} characters.`,
|
|
139
142
|
"error.noText": "The model returned no text.",
|
|
143
|
+
"error.network": "Network connection lost; failed to retrieve side-ask result.",
|
|
140
144
|
"error.provider": "The fork provider cannot inherit context with tools disabled. The side question was not started.",
|
|
141
145
|
"error.quotesTotalLength": `Total length of quoted selections exceeds the limit (max ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("en-US")} characters).`,
|
|
142
146
|
"error.reference": `Select 1\u2013${MAX_REFERENCE_LENGTH.toLocaleString("en-US")} characters of message text, including whitespace (some symbols count as multiple characters).`,
|
|
@@ -208,6 +212,7 @@ var ja = {
|
|
|
208
212
|
"command.description": "\u73FE\u5728\u306E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u306B\u57FA\u3065\u3044\u3066\u56DE\u7B54\uFF08\u30C4\u30FC\u30EB\u306F\u5B9F\u884C\u3057\u307E\u305B\u3093\uFF09",
|
|
209
213
|
"command.hint": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306E\u5185\u5BB9",
|
|
210
214
|
"command.internalClose": "\u6307\u5B9A\u3055\u308C\u305F BTW \u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u7D42\u4E86\u3057\u3066\u30AF\u30EA\u30FC\u30F3\u30A2\u30C3\u30D7",
|
|
215
|
+
"command.internalQuery": "BTW \u30B5\u30A4\u30C9\u8CEA\u554F\u30BF\u30B9\u30AF\u306E\u72B6\u614B\u3092\u7167\u4F1A",
|
|
211
216
|
"command.internalRun": "BTW \u30D0\u30D6\u30EB\u5185\u90E8\u30EA\u30AF\u30A8\u30B9\u30C8",
|
|
212
217
|
"command.label": "\u30B5\u30A4\u30C9\u8CEA\u554F",
|
|
213
218
|
"error.attachments": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u30C6\u30AD\u30B9\u30C8\u306E\u307F\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u3059\u3002\u753B\u50CF\u3084\u30D5\u30A1\u30A4\u30EB\u306F\u5165\u529B\u6B04\u306B\u6B8B\u308A\u307E\u3059\u3002",
|
|
@@ -226,6 +231,7 @@ var ja = {
|
|
|
226
231
|
"error.incomplete": "\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u5B8C\u4E86\u3057\u307E\u305B\u3093\u3067\u3057\u305F\uFF08{reason}\uFF09\u3002{detail}",
|
|
227
232
|
"error.length": `\u30B5\u30A4\u30C9\u8CEA\u554F\u306F\u6700\u5927 ${MAX_QUESTION_LENGTH.toLocaleString("ja-JP")} \u6587\u5B57\u307E\u3067\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u3059\u3002`,
|
|
228
233
|
"error.noText": "\u30E2\u30C7\u30EB\u304B\u3089\u30C6\u30AD\u30B9\u30C8\u306E\u56DE\u7B54\u304C\u8FD4\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
234
|
+
"error.network": "\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u304C\u5207\u65AD\u3055\u308C\u305F\u305F\u3081\u3001\u30B5\u30A4\u30C9\u8CEA\u554F\u306E\u7D50\u679C\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
229
235
|
"error.provider": "\u73FE\u5728\u306E fork \u30D7\u30ED\u30D0\u30A4\u30C0\u30FC\u306F\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u7D99\u627F\u3068\u30C4\u30FC\u30EB\u7121\u52B9\u5316\u3092\u540C\u6642\u306B\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
|
|
230
236
|
"error.quotesTotalLength": `\u5F15\u7528\u306E\u5408\u8A08\u6587\u5B57\u6570\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\uFF08\u6700\u5927 ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("ja-JP")} \u6587\u5B57\uFF09\u3002`,
|
|
231
237
|
"error.reference": `1\u301C${MAX_REFERENCE_LENGTH.toLocaleString("ja-JP")}\u6587\u5B57\u306E\u30C6\u30AD\u30B9\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u7A7A\u767D\u3092\u542B\u307F\u3001\u4E00\u90E8\u306E\u8A18\u53F7\u306F\u8907\u6570\u6587\u5B57\u3068\u3057\u3066\u30AB\u30A6\u30F3\u30C8\u3055\u308C\u307E\u3059\uFF09\u3002`,
|
|
@@ -297,6 +303,7 @@ var es = {
|
|
|
297
303
|
"command.description": "Responde seg\xFAn el contexto actual sin ejecutar herramientas",
|
|
298
304
|
"command.hint": "Pregunta secundaria",
|
|
299
305
|
"command.internalClose": "Cerrar y limpiar la solicitud BTW especificada",
|
|
306
|
+
"command.internalQuery": "Consultar estado de la tarea de pregunta secundaria BTW",
|
|
300
307
|
"command.internalRun": "Solicitud interna de burbuja BTW",
|
|
301
308
|
"command.label": "Pregunta secundaria",
|
|
302
309
|
"error.attachments": "Las preguntas secundarias solo aceptan texto. Las im\xE1genes y archivos permanecen en la entrada.",
|
|
@@ -315,6 +322,7 @@ var es = {
|
|
|
315
322
|
"error.incomplete": "La pregunta secundaria no se complet\xF3 ({reason}).{detail}",
|
|
316
323
|
"error.length": `Las preguntas secundarias admiten un m\xE1ximo de ${MAX_QUESTION_LENGTH.toLocaleString("es-ES")} caracteres.`,
|
|
317
324
|
"error.noText": "El modelo no devolvi\xF3 ninguna respuesta de texto.",
|
|
325
|
+
"error.network": "Conexi\xF3n de red perdida; no se pudo recuperar el resultado de la pregunta secundaria.",
|
|
318
326
|
"error.provider": "El proveedor de bifurcaci\xF3n no admite heredar contexto con herramientas deshabilitadas. La pregunta secundaria no se inici\xF3.",
|
|
319
327
|
"error.quotesTotalLength": `La longitud total de las citas supera el l\xEDmite (m\xE1ximo ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("es-ES")} caracteres).`,
|
|
320
328
|
"error.reference": `Seleccione entre 1 y ${MAX_REFERENCE_LENGTH.toLocaleString("es-ES")} caracteres de texto, incluidos espacios en blanco (algunos s\xEDmbolos cuentan como varios caracteres).`,
|
|
@@ -386,6 +394,7 @@ var fr = {
|
|
|
386
394
|
"command.description": "R\xE9pondre \xE0 partir du contexte actuel sans ex\xE9cuter d'outils",
|
|
387
395
|
"command.hint": "Question secondaire",
|
|
388
396
|
"command.internalClose": "Fermer et nettoyer la requ\xEAte BTW sp\xE9cifi\xE9e",
|
|
397
|
+
"command.internalQuery": "Interroger l'\xE9tat de la t\xE2che de question secondaire BTW",
|
|
389
398
|
"command.internalRun": "Requ\xEAte interne de bulle BTW",
|
|
390
399
|
"command.label": "Question secondaire",
|
|
391
400
|
"error.attachments": "Les questions secondaires n'acceptent que du texte. Les images et fichiers restent dans la zone de saisie.",
|
|
@@ -404,6 +413,7 @@ var fr = {
|
|
|
404
413
|
"error.incomplete": "La question secondaire ne s'est pas termin\xE9e ({reason}).{detail}",
|
|
405
414
|
"error.length": `Les questions secondaires sont limit\xE9es \xE0 ${MAX_QUESTION_LENGTH.toLocaleString("fr-FR")} caract\xE8res.`,
|
|
406
415
|
"error.noText": "Le mod\xE8le n'a renvoy\xE9 aucune r\xE9ponse textuelle.",
|
|
416
|
+
"error.network": "Connexion r\xE9seau perdue ; \xE9chec de la r\xE9cup\xE9ration du r\xE9sultat de la question secondaire.",
|
|
407
417
|
"error.provider": "Le fournisseur de fork ne prend pas en charge l'h\xE9ritage du contexte avec outils d\xE9sactiv\xE9s. La question secondaire n'a pas \xE9t\xE9 lanc\xE9e.",
|
|
408
418
|
"error.quotesTotalLength": `La longueur totale des citations d\xE9passe la limite (maximum ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("fr-FR")} caract\xE8res).`,
|
|
409
419
|
"error.reference": `S\xE9lectionnez entre 1 et ${MAX_REFERENCE_LENGTH.toLocaleString("fr-FR")} caract\xE8res de texte, espaces compris (certains symboles comptent pour plusieurs caract\xE8res).`,
|
|
@@ -475,6 +485,7 @@ var de = {
|
|
|
475
485
|
"command.description": "Aus aktuellem Kontext antworten, ohne Tools auszuf\xFChren",
|
|
476
486
|
"command.hint": "Nebenfrage",
|
|
477
487
|
"command.internalClose": "Angegebene BTW-Anfrage schlie\xDFen und bereinigen",
|
|
488
|
+
"command.internalQuery": "Status des BTW-Nebenfragenauftrags abfragen",
|
|
478
489
|
"command.internalRun": "Interne BTW-Sprechblasenanfrage",
|
|
479
490
|
"command.label": "Nebenfrage",
|
|
480
491
|
"error.attachments": "Nebenfragen akzeptieren nur Text. Bilder und Dateien verbleiben im Eingabefeld.",
|
|
@@ -493,6 +504,7 @@ var de = {
|
|
|
493
504
|
"error.incomplete": "Die Nebenfrage wurde nicht abgeschlossen ({reason}).{detail}",
|
|
494
505
|
"error.length": `Nebenfragen sind auf maximal ${MAX_QUESTION_LENGTH.toLocaleString("de-DE")} Zeichen begrenzt.`,
|
|
495
506
|
"error.noText": "Das Modell hat keine Textantwort zur\xFCckgegeben.",
|
|
507
|
+
"error.network": "Netzwerkverbindung unterbrochen; Ergebnis der Nebenfrage konnte nicht abgerufen werden.",
|
|
496
508
|
"error.provider": "Der Fork-Provider unterst\xFCtzt die Vererbung des Kontexts bei deaktivierten Tools nicht. Die Nebenfrage wurde nicht gestartet.",
|
|
497
509
|
"error.quotesTotalLength": `Die Gesamtl\xE4nge der Zitate \xFCberschreitet das Limit (maximal ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("de-DE")} Zeichen).`,
|
|
498
510
|
"error.reference": `W\xE4hlen Sie 1 bis ${MAX_REFERENCE_LENGTH.toLocaleString("de-DE")} Textzeichen aus, einschlie\xDFlich Leerzeichen (einige Symbole z\xE4hlen als mehrere Zeichen).`,
|
|
@@ -564,6 +576,7 @@ var ru = {
|
|
|
564
576
|
"command.description": "\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C \u043D\u0430 \u043E\u0441\u043D\u043E\u0432\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430 \u0431\u0435\u0437 \u0432\u044B\u0437\u043E\u0432\u0430 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u0432",
|
|
565
577
|
"command.hint": "\u0422\u0435\u043A\u0441\u0442 \u043F\u043E\u0431\u043E\u0447\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430",
|
|
566
578
|
"command.internalClose": "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0438 \u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0443\u043A\u0430\u0437\u0430\u043D\u043D\u044B\u0439 \u0437\u0430\u043F\u0440\u043E\u0441 BTW",
|
|
579
|
+
"command.internalQuery": "\u0417\u0430\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u0434\u0430\u0447\u0438 \u043F\u043E\u043F\u0443\u0442\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430 BTW",
|
|
567
580
|
"command.internalRun": "\u0412\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u0438\u0439 \u0437\u0430\u043F\u0440\u043E\u0441 \u043F\u0443\u0437\u044B\u0440\u044F BTW",
|
|
568
581
|
"command.label": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441",
|
|
569
582
|
"error.attachments": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0435 \u0432\u043E\u043F\u0440\u043E\u0441\u044B \u043F\u0440\u0438\u043D\u0438\u043C\u0430\u044E\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0442\u0435\u043A\u0441\u0442. \u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u0438 \u0444\u0430\u0439\u043B\u044B \u043E\u0441\u0442\u0430\u043D\u0443\u0442\u0441\u044F \u0432 \u043F\u043E\u043B\u0435 \u0432\u0432\u043E\u0434\u0430.",
|
|
@@ -582,6 +595,7 @@ var ru = {
|
|
|
582
595
|
"error.incomplete": "\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D ({reason}).{detail}",
|
|
583
596
|
"error.length": `\u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 ${MAX_QUESTION_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432.`,
|
|
584
597
|
"error.noText": "\u041C\u043E\u0434\u0435\u043B\u044C \u043D\u0435 \u0432\u0435\u0440\u043D\u0443\u043B\u0430 \u0442\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u043E\u0442\u0432\u0435\u0442.",
|
|
598
|
+
"error.network": "\u0421\u0435\u0442\u0435\u0432\u043E\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0435 \u0440\u0430\u0437\u043E\u0440\u0432\u0430\u043D\u043E; \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u043F\u043E\u043F\u0443\u0442\u043D\u043E\u0433\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u0430.",
|
|
585
599
|
"error.provider": "\u0422\u0435\u043A\u0443\u0449\u0438\u0439 fork provider \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043D\u0430\u0441\u043B\u0435\u0434\u043E\u0432\u0430\u043D\u0438\u0435 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0430 \u0441 \u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u043D\u044B\u043C\u0438 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0430\u043C\u0438. \u041F\u043E\u0431\u043E\u0447\u043D\u044B\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D.",
|
|
586
600
|
"error.quotesTotalLength": `\u041E\u0431\u0449\u0430\u044F \u0434\u043B\u0438\u043D\u0430 \u0446\u0438\u0442\u0430\u0442 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u043B\u0438\u043C\u0438\u0442 (\u043C\u0430\u043A\u0441\u0438\u043C\u0443\u043C ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432).`,
|
|
587
601
|
"error.reference": `\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043E\u0442 1 \u0434\u043E ${MAX_REFERENCE_LENGTH.toLocaleString("ru-RU")} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432 \u0442\u0435\u043A\u0441\u0442\u0430, \u0432\u043A\u043B\u044E\u0447\u0430\u044F \u043F\u0440\u043E\u0431\u0435\u043B\u044B (\u043D\u0435\u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u0441\u0447\u0438\u0442\u0430\u044E\u0442\u0441\u044F \u0437\u0430 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E).`,
|
|
@@ -653,6 +667,7 @@ var pt = {
|
|
|
653
667
|
"command.description": "Responder com base no contexto atual sem executar ferramentas",
|
|
654
668
|
"command.hint": "Conte\xFAdo da pergunta secund\xE1ria",
|
|
655
669
|
"command.internalClose": "Fechar e limpar a solicita\xE7\xE3o BTW especificada",
|
|
670
|
+
"command.internalQuery": "Consultar status da tarefa de pergunta secund\xE1ria BTW",
|
|
656
671
|
"command.internalRun": "Solicita\xE7\xE3o interna de bal\xE3o BTW",
|
|
657
672
|
"command.label": "Pergunta secund\xE1ria",
|
|
658
673
|
"error.attachments": "As perguntas secund\xE1rias aceitam apenas texto. As imagens e arquivos continuam no campo de entrada.",
|
|
@@ -671,6 +686,7 @@ var pt = {
|
|
|
671
686
|
"error.incomplete": "A pergunta secund\xE1ria n\xE3o foi conclu\xEDda ({reason}).{detail}",
|
|
672
687
|
"error.length": `As perguntas secund\xE1rias s\xE3o limitadas a ${MAX_QUESTION_LENGTH.toLocaleString("pt-BR")} caracteres.`,
|
|
673
688
|
"error.noText": "O modelo n\xE3o retornou nenhuma resposta em texto.",
|
|
689
|
+
"error.network": "Conex\xE3o de rede perdida; falha ao recuperar o resultado da pergunta secund\xE1ria.",
|
|
674
690
|
"error.provider": "O provedor de fork n\xE3o suporta herdar o contexto com as ferramentas desativadas. A pergunta secund\xE1ria n\xE3o foi iniciada.",
|
|
675
691
|
"error.quotesTotalLength": `O comprimento total das cita\xE7\xF5es excede o limite (m\xE1ximo ${MAX_TOTAL_QUOTES_LENGTH.toLocaleString("pt-BR")} caracteres).`,
|
|
676
692
|
"error.reference": `Selecione de 1 a ${MAX_REFERENCE_LENGTH.toLocaleString("pt-BR")} caracteres de texto, incluindo espa\xE7os em branco (alguns s\xEDmbolos contam como m\xFAltiplos caracteres).`,
|
|
@@ -755,6 +771,10 @@ function normalizeLocale(value) {
|
|
|
755
771
|
// src/shared.ts
|
|
756
772
|
var RUN_COMMAND = "btw-run";
|
|
757
773
|
var CLOSE_COMMAND = "btw-close";
|
|
774
|
+
var QUERY_COMMAND = "btw-query";
|
|
775
|
+
var INTERNAL_COMMANDS = [RUN_COMMAND, CLOSE_COMMAND, QUERY_COMMAND];
|
|
776
|
+
var JOB_ROUTE_PATH = "/api/michengai-btw/job";
|
|
777
|
+
var DEFAULT_TIMEOUT_MS = 18e5;
|
|
758
778
|
function parseRequest(raw) {
|
|
759
779
|
if (raw.length > (MAX_QUESTION_LENGTH + MAX_REFERENCE_LENGTH) * 6 + 1024) throw new Error(translate()("error.requestLength"));
|
|
760
780
|
let value;
|
|
@@ -814,7 +834,6 @@ function sanitizeModelAnswer(raw) {
|
|
|
814
834
|
if (!raw) return "";
|
|
815
835
|
return raw.replace(/<tool_call>[\s\S]*?<\/tool_call>/gi, "").replace(/<function_call>[\s\S]*?<\/function_call>/gi, "").replace(/```(?:tool_call|function_call)[\s\S]*?```/gi, "").trim();
|
|
816
836
|
}
|
|
817
|
-
var DEFAULT_TIMEOUT_MS = 18e5;
|
|
818
837
|
var SideJobs = class {
|
|
819
838
|
constructor(start, timeoutMs = DEFAULT_TIMEOUT_MS, options = {}) {
|
|
820
839
|
this.start = start;
|
|
@@ -823,6 +842,7 @@ var SideJobs = class {
|
|
|
823
842
|
}
|
|
824
843
|
jobs = /* @__PURE__ */ new Map();
|
|
825
844
|
retired = /* @__PURE__ */ new Map();
|
|
845
|
+
completed = /* @__PURE__ */ new Map();
|
|
826
846
|
disposed = false;
|
|
827
847
|
idleNotified = false;
|
|
828
848
|
get size() {
|
|
@@ -832,27 +852,36 @@ var SideJobs = class {
|
|
|
832
852
|
const key = JSON.stringify([scope, id]);
|
|
833
853
|
const t = translate(locale);
|
|
834
854
|
this.prune();
|
|
855
|
+
if (signal?.aborted) return Promise.resolve(failure(t("error.cancelled")));
|
|
835
856
|
if (this.disposed) return Promise.resolve(failure(t("error.stopped")));
|
|
836
857
|
if (this.jobs.has(key) || this.retired.has(key)) return Promise.resolve(failure(t("error.duplicate")));
|
|
837
858
|
if (this.jobs.size >= 8) return Promise.resolve(failure(t("error.capacity")));
|
|
838
859
|
const job = { key, controller: new AbortController(), finished: Promise.resolve({ kind: "success", text: "" }), t };
|
|
839
860
|
this.jobs.set(key, job);
|
|
840
|
-
const cancel = () => job.controller.abort(new Error(t("error.cancelled")));
|
|
841
|
-
signal?.addEventListener("abort", cancel, { once: true });
|
|
842
|
-
if (signal?.aborted) cancel();
|
|
843
861
|
const timer = this.timeoutMs > 0 ? setTimeout(() => job.controller.abort(new Error(t("error.timeout"))), this.timeoutMs) : void 0;
|
|
844
862
|
timer?.unref?.();
|
|
845
|
-
job.finished = this.execute(job, { scope, id, question, signal: job.controller.signal, context, locale }).
|
|
863
|
+
job.finished = this.execute(job, { scope, id, question, signal: job.controller.signal, context, locale }).then((result) => {
|
|
864
|
+
this.completed.set(key, { result, time: Date.now() });
|
|
865
|
+
return result;
|
|
866
|
+
}).finally(() => {
|
|
846
867
|
if (timer) clearTimeout(timer);
|
|
847
|
-
signal?.removeEventListener("abort", cancel);
|
|
848
868
|
this.release(job);
|
|
849
869
|
});
|
|
850
|
-
return job.finished;
|
|
870
|
+
return signal ? this.interruptible(job.finished, signal).catch((error) => failure(error)) : job.finished;
|
|
871
|
+
}
|
|
872
|
+
query(scope, id) {
|
|
873
|
+
const key = JSON.stringify([scope, id]);
|
|
874
|
+
this.prune();
|
|
875
|
+
if (this.jobs.has(key)) return { state: "running" };
|
|
876
|
+
const cached = this.completed.get(key);
|
|
877
|
+
if (cached) return { state: "done", result: cached.result };
|
|
878
|
+
return { state: "not-found" };
|
|
851
879
|
}
|
|
852
880
|
/** 关闭可先于启动到达;短期墓碑阻止网络乱序重新启动请求。 */
|
|
853
881
|
async close(scope, id) {
|
|
854
882
|
const key = JSON.stringify([scope, id]);
|
|
855
883
|
this.retire(key);
|
|
884
|
+
this.completed.delete(key);
|
|
856
885
|
const job = this.jobs.get(key);
|
|
857
886
|
if (!job) return { kind: "success", text: "" };
|
|
858
887
|
job.controller.abort(new Error(job.t("error.cancelled")));
|
|
@@ -997,7 +1026,26 @@ ${text}` : "" }));
|
|
|
997
1026
|
this.prune();
|
|
998
1027
|
}
|
|
999
1028
|
prune() {
|
|
1000
|
-
|
|
1029
|
+
const now = Date.now();
|
|
1030
|
+
for (const [key, time] of this.retired) {
|
|
1031
|
+
if (now - time > 3e5 || this.retired.size > 1e3) this.retired.delete(key);
|
|
1032
|
+
}
|
|
1033
|
+
for (const [key, item] of this.completed) {
|
|
1034
|
+
if (now - item.time > 3e5) {
|
|
1035
|
+
this.completed.delete(key);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
let totalChars = 0;
|
|
1039
|
+
for (const [, item] of this.completed) {
|
|
1040
|
+
totalChars += item.result.text.length;
|
|
1041
|
+
}
|
|
1042
|
+
if (this.completed.size > 1e3 || totalChars > 2e6) {
|
|
1043
|
+
for (const [key, item] of this.completed) {
|
|
1044
|
+
if (this.completed.size <= 1e3 && totalChars <= 2e6) break;
|
|
1045
|
+
totalChars -= item.result.text.length;
|
|
1046
|
+
this.completed.delete(key);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1001
1049
|
}
|
|
1002
1050
|
};
|
|
1003
1051
|
|
|
@@ -1203,13 +1251,14 @@ function readSettings(raw) {
|
|
|
1203
1251
|
}
|
|
1204
1252
|
|
|
1205
1253
|
// src/server/command-visibility.ts
|
|
1254
|
+
var internalCommandNames = new Set(INTERNAL_COMMANDS);
|
|
1206
1255
|
function hideInternalCommands(commands) {
|
|
1207
1256
|
const descriptor = Object.getOwnPropertyDescriptor(commands, "list");
|
|
1208
1257
|
const original = commands.list;
|
|
1209
1258
|
let active = true;
|
|
1210
1259
|
const filtered = function(agent) {
|
|
1211
1260
|
const rows = original.call(this, agent);
|
|
1212
|
-
return active ? Object.freeze(rows.filter((row) =>
|
|
1261
|
+
return active ? Object.freeze(rows.filter((row) => !internalCommandNames.has(row.name))) : rows;
|
|
1213
1262
|
};
|
|
1214
1263
|
Object.defineProperty(commands, "list", { configurable: true, writable: true, value: filtered });
|
|
1215
1264
|
return () => {
|
|
@@ -1422,7 +1471,19 @@ ${request.question}`;
|
|
|
1422
1471
|
const question = invocation.rawInput.trim();
|
|
1423
1472
|
if (!question) return { kind: "error", text: translate()("error.empty") };
|
|
1424
1473
|
if (question.length > MAX_QUESTION_LENGTH) return { kind: "error", text: translate()("error.length") };
|
|
1425
|
-
|
|
1474
|
+
const sessionId = invocation.agent.session.header.id;
|
|
1475
|
+
const id = globalThis.crypto.randomUUID();
|
|
1476
|
+
const task = jobs.ask(sessionId, id, question, invocation.signal, invocation.agent);
|
|
1477
|
+
if (invocation.signal) {
|
|
1478
|
+
const onAbort = () => {
|
|
1479
|
+
void jobs.close(sessionId, id);
|
|
1480
|
+
};
|
|
1481
|
+
invocation.signal.addEventListener("abort", onAbort, { once: true });
|
|
1482
|
+
void task.finally(() => {
|
|
1483
|
+
invocation.signal?.removeEventListener("abort", onAbort);
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
return task;
|
|
1426
1487
|
}
|
|
1427
1488
|
}));
|
|
1428
1489
|
ctx.effect(() => ctx.commands.register({
|
|
@@ -1448,6 +1509,40 @@ ${request.question}`;
|
|
|
1448
1509
|
return jobs.close(invocation.agent.session.header.id, id);
|
|
1449
1510
|
}
|
|
1450
1511
|
}));
|
|
1512
|
+
ctx.effect(() => ctx.commands.register({
|
|
1513
|
+
name: QUERY_COMMAND,
|
|
1514
|
+
description: translate()("command.internalQuery"),
|
|
1515
|
+
recordInput: false,
|
|
1516
|
+
handler: (invocation) => {
|
|
1517
|
+
const id = invocation.rawInput.trim();
|
|
1518
|
+
if (!/^[a-zA-Z0-9-]{8,80}$/.test(id)) return { kind: "error", text: translate()("error.id") };
|
|
1519
|
+
const status = jobs.query(invocation.agent.session.header.id, id);
|
|
1520
|
+
return { kind: "success", text: JSON.stringify(status) };
|
|
1521
|
+
}
|
|
1522
|
+
}));
|
|
1523
|
+
const registerConnectionFetch = (connection, scope) => {
|
|
1524
|
+
const conn = connection;
|
|
1525
|
+
if (conn?.fetch) {
|
|
1526
|
+
scope.effect(() => conn.fetch.register({
|
|
1527
|
+
path: JOB_ROUTE_PATH,
|
|
1528
|
+
methods: ["GET"],
|
|
1529
|
+
requestBody: "buffered",
|
|
1530
|
+
fetch: async (request) => {
|
|
1531
|
+
const url = new URL(request.url);
|
|
1532
|
+
const session = url.searchParams.get("session");
|
|
1533
|
+
const id = url.searchParams.get("id");
|
|
1534
|
+
if (!session || !id) return new Response(JSON.stringify({ error: "missing session or id" }), { status: 400, headers: { "Content-Type": "application/json" } });
|
|
1535
|
+
const status = jobs.query(session, id);
|
|
1536
|
+
return new Response(JSON.stringify(status), { status: 200, headers: { "Content-Type": "application/json" } });
|
|
1537
|
+
}
|
|
1538
|
+
}));
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
if (typeof ctx.inject === "function") {
|
|
1542
|
+
ctx.inject(["connection"], (scope) => registerConnectionFetch(scope.get("connection"), scope));
|
|
1543
|
+
} else {
|
|
1544
|
+
registerConnectionFetch(ctx.get("connection"), ctx);
|
|
1545
|
+
}
|
|
1451
1546
|
}
|
|
1452
1547
|
export {
|
|
1453
1548
|
Config,
|
|
@@ -18,6 +18,7 @@ export declare const zh: {
|
|
|
18
18
|
readonly "command.description": "根据当前上下文回答,不执行工具";
|
|
19
19
|
readonly "command.hint": "旁问内容";
|
|
20
20
|
readonly "command.internalClose": "关闭并清理指定 BTW 请求";
|
|
21
|
+
readonly "command.internalQuery": "查询 BTW 旁问任务状态";
|
|
21
22
|
readonly "command.internalRun": "BTW 气泡内部请求";
|
|
22
23
|
readonly "command.label": "旁问";
|
|
23
24
|
readonly "error.attachments": "旁问只接受文字,图片和文件仍保留在输入框中。";
|
|
@@ -36,6 +37,7 @@ export declare const zh: {
|
|
|
36
37
|
readonly "error.incomplete": "旁问未完成({reason})。{detail}";
|
|
37
38
|
readonly "error.length": "旁问最多支持 8000 个字符。";
|
|
38
39
|
readonly "error.noText": "模型未返回文字回答。";
|
|
40
|
+
readonly "error.network": "网络连接中断,无法取回旁问结果。";
|
|
39
41
|
readonly "error.provider": "当前 fork provider 不支持继承上下文并禁用工具,旁问未启动。";
|
|
40
42
|
readonly "error.quotesTotalLength": `\u5F15\u7528\u5408\u8BA1\u957F\u5EA6\u8D85\u51FA\u4E0A\u9650\uFF08\u6700\u591A ${string} \u5B57\u7B26\uFF09\u3002`;
|
|
41
43
|
readonly "error.reference": "请选择 1–8000 个字符的正文(含空白,部分符号计为多个字符)。";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { DEFAULT_TIMEOUT_MS, type SideJobStatus, type SideResult } from '../shared';
|
|
2
|
+
export { DEFAULT_TIMEOUT_MS };
|
|
2
3
|
import { type BtwLocale } from '../locales';
|
|
3
4
|
export interface ChildResult {
|
|
4
5
|
stopReason: string;
|
|
@@ -28,7 +29,6 @@ interface JobOptions {
|
|
|
28
29
|
}
|
|
29
30
|
/** 清洗模型可能因上下文 toolcall 惯性残留的裸露工具调用标记与代码块伪影,保留纯文字回答 */
|
|
30
31
|
export declare function sanitizeModelAnswer(raw: string): string;
|
|
31
|
-
export declare const DEFAULT_TIMEOUT_MS = 1800000;
|
|
32
32
|
/** 管理一次性任务;父会话和请求标识共同构成所有权边界。 */
|
|
33
33
|
export declare class SideJobs {
|
|
34
34
|
private readonly start;
|
|
@@ -36,11 +36,13 @@ export declare class SideJobs {
|
|
|
36
36
|
private readonly options;
|
|
37
37
|
private readonly jobs;
|
|
38
38
|
private readonly retired;
|
|
39
|
+
private readonly completed;
|
|
39
40
|
private disposed;
|
|
40
41
|
private idleNotified;
|
|
41
42
|
constructor(start: StartChild, timeoutMs?: number, options?: JobOptions);
|
|
42
43
|
get size(): number;
|
|
43
44
|
ask(scope: string, id: string, question: string, signal?: AbortSignal, context?: unknown, locale?: BtwLocale): Promise<SideResult>;
|
|
45
|
+
query(scope: string, id: string): SideJobStatus;
|
|
44
46
|
/** 关闭可先于启动到达;短期墓碑阻止网络乱序重新启动请求。 */
|
|
45
47
|
close(scope: string, id: string): Promise<SideResult>;
|
|
46
48
|
dispose(): Promise<void>;
|
|
@@ -55,4 +57,3 @@ export declare class SideJobs {
|
|
|
55
57
|
private retire;
|
|
56
58
|
private prune;
|
|
57
59
|
}
|
|
58
|
-
export {};
|
package/lib/types/shared.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ export { MAX_QUESTION_LENGTH, MAX_REFERENCE_LENGTH, MAX_TOTAL_QUOTES_LENGTH } fr
|
|
|
2
2
|
import { type BtwLocale } from './locales';
|
|
3
3
|
export declare const RUN_COMMAND = "btw-run";
|
|
4
4
|
export declare const CLOSE_COMMAND = "btw-close";
|
|
5
|
+
export declare const QUERY_COMMAND = "btw-query";
|
|
6
|
+
export declare const INTERNAL_COMMANDS: readonly ["btw-run", "btw-close", "btw-query"];
|
|
7
|
+
export declare const JOB_ROUTE_PATH = "/api/michengai-btw/job";
|
|
8
|
+
export declare const DEFAULT_TIMEOUT_MS = 1800000;
|
|
9
|
+
export type SideJobState = 'running' | 'done' | 'not-found';
|
|
10
|
+
export interface SideJobStatus {
|
|
11
|
+
state: SideJobState;
|
|
12
|
+
result?: SideResult;
|
|
13
|
+
}
|
|
5
14
|
export interface SideRequest {
|
|
6
15
|
id: string;
|
|
7
16
|
question: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-btw",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "DSH 一次性只读旁问插件:基于当前上下文回答,独立气泡,不执行工具 · One-shot read-only side-ask plugin: answers from current context in an independent bubble, no tool execution",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|