@tunnelbox/claude-code 0.1.7 → 0.1.9
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/dist/index.mjs +131 -3
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -103,6 +103,9 @@ var zh_CN_default = {
|
|
|
103
103
|
"agent.log.gotPermReply": "\u6536\u5230\u624B\u673A\u6743\u9650\u56DE\u590D (id={id} {reply} {version})",
|
|
104
104
|
"agent.log.gotQuestionReply": "\u6536\u5230\u624B\u673A\u63D0\u95EE\u56DE\u590D (id={id} {status} {version})",
|
|
105
105
|
"agent.log.handleFailed": "\u5904\u7406 {type} \u5931\u8D25: {message}",
|
|
106
|
+
"agent.log.msgOk": "\u62C9\u53D6\u4F1A\u8BDD\u6D88\u606F\u6210\u529F session={session} data={count} \u65B9\u5F0F={limited} win={win} ms={ms}",
|
|
107
|
+
"agent.log.msgFailed": "\u62C9\u53D6\u4F1A\u8BDD\u6D88\u606F\u5931\u8D25 session={session} err={err} ms={ms}",
|
|
108
|
+
"agent.log.msgLimitFallback": "\u5F53\u524D opencode \u4E0D\u652F\u6301 limit\uFF0C\u56DE\u9000\u5168\u91CF\u62C9\u53D6\uFF08session={session}\uFF09",
|
|
106
109
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
107
110
|
"agent.log.pendingResent": "session.pending: \u8865\u53D1 {session} \u79EF\u538B\u8BF7\u6C42 {count} \u6761",
|
|
108
111
|
"agent.log.unhandledType": "\u672A\u5904\u7406\u7684\u6D88\u606F\u7C7B\u578B: {type}",
|
|
@@ -114,6 +117,7 @@ var zh_CN_default = {
|
|
|
114
117
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5BF9\u7801\u8D85\u65F6\uFF08\u4E2D\u7EE7\u672A\u54CD\u5E94\uFF09",
|
|
115
118
|
"index.log.claimed": "\u5DF2\u7ED1\u5B9A\u5230\u624B\u673A\u8D26\u53F7\uFF0C\u4E4B\u540E\u624B\u673A\u4ECE\u300C\u6211\u7684\u7535\u8111\u300D\u76F4\u63A5\u8FDE\u63A5\uFF0C\u65E0\u9700\u518D\u626B\u7801",
|
|
116
119
|
"index.log.connectedRelay": "\u5DF2\u8FDE\u63A5\u4E2D\u7EE7 {url}",
|
|
120
|
+
"index.log.loaded": "tunnelbox opencode \u63D2\u4EF6\u5DF2\u542F\u52A8\uFF08v{version}\uFF09",
|
|
117
121
|
"index.log.disconnected": "\u4E0E\u4E2D\u7EE7\u65AD\u5F00\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8FDE\u2026",
|
|
118
122
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
119
123
|
"index.log.pairCode": "\u751F\u6210\u914D\u5BF9\u7801: {code}",
|
|
@@ -264,6 +268,9 @@ var zh_TW_default = {
|
|
|
264
268
|
"agent.log.gotPermReply": "\u6536\u5230\u624B\u6A5F\u6B0A\u9650\u56DE\u8986 (id={id} {reply} {version})",
|
|
265
269
|
"agent.log.gotQuestionReply": "\u6536\u5230\u624B\u6A5F\u63D0\u554F\u56DE\u8986 (id={id} {status} {version})",
|
|
266
270
|
"agent.log.handleFailed": "\u8655\u7406 {type} \u5931\u6557: {message}",
|
|
271
|
+
"agent.log.msgOk": "\u53D6\u5F97\u6703\u8A71\u8A0A\u606F\u6210\u529F session={session} data={count} \u65B9\u5F0F={limited} win={win} ms={ms}",
|
|
272
|
+
"agent.log.msgFailed": "\u53D6\u5F97\u6703\u8A71\u8A0A\u606F\u5931\u6557 session={session} err={err} ms={ms}",
|
|
273
|
+
"agent.log.msgLimitFallback": "\u76EE\u524D\u7684 opencode \u4E0D\u652F\u63F4 limit\uFF0C\u6539\u70BA\u5168\u91CF\u53D6\u5F97\uFF08session={session}\uFF09",
|
|
267
274
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
268
275
|
"agent.log.pendingResent": "session.pending: \u88DC\u767C {session} \u7A4D\u58D3\u8ACB\u6C42 {count} \u689D",
|
|
269
276
|
"agent.log.unhandledType": "\u672A\u8655\u7406\u7684\u8A0A\u606F\u985E\u578B: {type}",
|
|
@@ -275,6 +282,7 @@ var zh_TW_default = {
|
|
|
275
282
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5C0D\u78BC\u903E\u6642\uFF08\u4E2D\u7E7C\u672A\u56DE\u61C9\uFF09",
|
|
276
283
|
"index.log.claimed": "\u5DF2\u7D81\u5B9A\u5230\u624B\u6A5F\u5E33\u865F\uFF0C\u4E4B\u5F8C\u624B\u6A5F\u76F4\u63A5\u5F9E\u300C\u6211\u7684\u96FB\u8166\u300D\u9023\u63A5\uFF0C\u4E0D\u9700\u518D\u6383\u78BC",
|
|
277
284
|
"index.log.connectedRelay": "\u5DF2\u9023\u63A5\u4E2D\u7E7C {url}",
|
|
285
|
+
"index.log.loaded": "tunnelbox opencode \u5916\u639B\u5DF2\u555F\u52D5\uFF08v{version}\uFF09",
|
|
278
286
|
"index.log.disconnected": "\u8207\u4E2D\u7E7C\u65B7\u7DDA\uFF0C\u6B63\u5728\u81EA\u52D5\u91CD\u9023\u2026",
|
|
279
287
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
280
288
|
"index.log.pairCode": "\u7522\u751F\u914D\u5C0D\u78BC: {code}",
|
|
@@ -425,6 +433,9 @@ var en_US_default = {
|
|
|
425
433
|
"agent.log.gotPermReply": "Received permission reply from phone (id={id} {reply} {version})",
|
|
426
434
|
"agent.log.gotQuestionReply": "Received question reply from phone (id={id} {status} {version})",
|
|
427
435
|
"agent.log.handleFailed": "Failed to handle {type}: {message}",
|
|
436
|
+
"agent.log.msgOk": "session.messages OK session={session} data={count} limited={limited} win={win} ms={ms}",
|
|
437
|
+
"agent.log.msgFailed": "session.messages FAILED session={session} err={err} ms={ms}",
|
|
438
|
+
"agent.log.msgLimitFallback": "limit unsupported, fell back to full session fetch (session={session})",
|
|
428
439
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
429
440
|
"agent.log.pendingResent": "session.pending: resent {count} pending request(s) for {session}",
|
|
430
441
|
"agent.log.unhandledType": "Unhandled message type: {type}",
|
|
@@ -436,6 +447,7 @@ var en_US_default = {
|
|
|
436
447
|
"index.error.pairTimeout": "Timed out waiting for a pairing code (the relay did not respond)",
|
|
437
448
|
"index.log.claimed": "Bound to your phone account. From now on the phone connects directly from My Computers; no need to scan again",
|
|
438
449
|
"index.log.connectedRelay": "Connected to relay {url}",
|
|
450
|
+
"index.log.loaded": "tunnelbox opencode plugin started (v{version})",
|
|
439
451
|
"index.log.disconnected": "Disconnected from relay, reconnecting automatically\u2026",
|
|
440
452
|
"index.log.exit": "Exited",
|
|
441
453
|
"index.log.pairCode": "Generated pairing code: {code}",
|
|
@@ -586,6 +598,9 @@ var ja_JP_default = {
|
|
|
586
598
|
"agent.log.gotPermReply": "\u643A\u5E2F\u304B\u3089\u6A29\u9650\u306E\u8FD4\u4FE1\u3092\u53D7\u4FE1 (id={id} {reply} {version})",
|
|
587
599
|
"agent.log.gotQuestionReply": "\u643A\u5E2F\u304B\u3089\u8CEA\u554F\u306E\u8FD4\u4FE1\u3092\u53D7\u4FE1 (id={id} {status} {version})",
|
|
588
600
|
"agent.log.handleFailed": "{type} \u306E\u51E6\u7406\u306B\u5931\u6557: {message}",
|
|
601
|
+
"agent.log.msgOk": "\u30BB\u30C3\u30B7\u30E7\u30F3\u30E1\u30C3\u30BB\u30FC\u30B8\u53D6\u5F97\u6210\u529F session={session} data={count} \u65B9\u5F0F={limited} win={win} ms={ms}",
|
|
602
|
+
"agent.log.msgFailed": "\u30BB\u30C3\u30B7\u30E7\u30F3\u30E1\u30C3\u30BB\u30FC\u30B8\u53D6\u5F97\u5931\u6557 session={session} err={err} ms={ms}",
|
|
603
|
+
"agent.log.msgLimitFallback": "\u3053\u306E opencode \u306F limit \u975E\u5BFE\u5FDC\u306E\u305F\u3081\u5168\u91CF\u53D6\u5F97\u306B\u30D5\u30A9\u30FC\u30EB\u30D0\u30C3\u30AF\uFF08session={session}\uFF09",
|
|
589
604
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
590
605
|
"agent.log.pendingResent": "session.pending: {session} \u306E\u4FDD\u7559\u30EA\u30AF\u30A8\u30B9\u30C8 {count} \u4EF6\u3092\u518D\u9001",
|
|
591
606
|
"agent.log.unhandledType": "\u672A\u51E6\u7406\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u30BF\u30A4\u30D7: {type}",
|
|
@@ -597,6 +612,7 @@ var ja_JP_default = {
|
|
|
597
612
|
"index.error.pairTimeout": "\u30DA\u30A2\u30EA\u30F3\u30B0\u30B3\u30FC\u30C9\u306E\u53D6\u5F97\u304C\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F\uFF08\u30EA\u30EC\u30FC\u304C\u5FDC\u7B54\u3057\u307E\u305B\u3093\uFF09",
|
|
598
613
|
"index.log.claimed": "\u30B9\u30DE\u30DB\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u7D10\u4ED8\u3051\u307E\u3057\u305F\u3002\u4EE5\u964D\u306F\u300C\u30DE\u30A4 PC\u300D\u304B\u3089\u76F4\u63A5\u63A5\u7D9A\u3055\u308C\u308B\u305F\u3081\u3001\u518D\u30B9\u30AD\u30E3\u30F3\u306F\u4E0D\u8981\u3067\u3059",
|
|
599
614
|
"index.log.connectedRelay": "\u30EA\u30EC\u30FC\u306B\u63A5\u7D9A\u3057\u307E\u3057\u305F {url}",
|
|
615
|
+
"index.log.loaded": "tunnelbox opencode \u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u8D77\u52D5\u3057\u307E\u3057\u305F\uFF08v{version}\uFF09",
|
|
600
616
|
"index.log.disconnected": "\u30EA\u30EC\u30FC\u304B\u3089\u5207\u65AD\u3001\u81EA\u52D5\u7684\u306B\u518D\u63A5\u7D9A\u3057\u3066\u3044\u307E\u3059\u2026",
|
|
601
617
|
"index.log.exit": "\u7D42\u4E86\u3057\u307E\u3057\u305F",
|
|
602
618
|
"index.log.pairCode": "\u30DA\u30A2\u30EA\u30F3\u30B0\u30B3\u30FC\u30C9\u3092\u751F\u6210: {code}",
|
|
@@ -747,6 +763,9 @@ var ko_KR_default = {
|
|
|
747
763
|
"agent.log.gotPermReply": "\uD734\uB300\uD3F0\uC5D0\uC11C \uAD8C\uD55C \uC751\uB2F5 \uC218\uC2E0 (id={id} {reply} {version})",
|
|
748
764
|
"agent.log.gotQuestionReply": "\uD734\uB300\uD3F0\uC5D0\uC11C \uC9C8\uBB38 \uC751\uB2F5 \uC218\uC2E0 (id={id} {status} {version})",
|
|
749
765
|
"agent.log.handleFailed": "{type} \uCC98\uB9AC \uC2E4\uD328: {message}",
|
|
766
|
+
"agent.log.msgOk": "\uC138\uC158 \uBA54\uC2DC\uC9C0 \uC870\uD68C \uC131\uACF5 session={session} data={count} \uBC29\uC2DD={limited} win={win} ms={ms}",
|
|
767
|
+
"agent.log.msgFailed": "\uC138\uC158 \uBA54\uC2DC\uC9C0 \uC870\uD68C \uC2E4\uD328 session={session} err={err} ms={ms}",
|
|
768
|
+
"agent.log.msgLimitFallback": "\uC774 opencode\uB294 limit \uBBF8\uC9C0\uC6D0 \u2192 \uC804\uCCB4 \uC870\uD68C\uB85C \uD3F4\uBC31 (session={session})",
|
|
750
769
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
751
770
|
"agent.log.pendingResent": "session.pending: {session} \uBCF4\uB958 \uC694\uCCAD {count}\uAC74 \uC7AC\uC804\uC1A1",
|
|
752
771
|
"agent.log.unhandledType": "\uCC98\uB9AC\uB418\uC9C0 \uC54A\uC740 \uBA54\uC2DC\uC9C0 \uC720\uD615: {type}",
|
|
@@ -758,6 +777,7 @@ var ko_KR_default = {
|
|
|
758
777
|
"index.error.pairTimeout": "\uD398\uC5B4\uB9C1 \uCF54\uB4DC \uB300\uAE30 \uC2DC\uAC04 \uCD08\uACFC(\uB9B4\uB808\uC774\uAC00 \uC751\uB2F5\uD558\uC9C0 \uC54A\uC74C)",
|
|
759
778
|
"index.log.claimed": "\uD734\uB300\uD3F0 \uACC4\uC815\uC5D0 \uC5F0\uACB0\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uC774\uC81C \uD734\uB300\uD3F0\uC740 \u300C\uB0B4 PC\u300D\uC5D0\uC11C \uC9C1\uC811 \uC5F0\uACB0\uD558\uBA70 \uB2E4\uC2DC \uC2A4\uCE94\uD560 \uD544\uC694\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4",
|
|
760
779
|
"index.log.connectedRelay": "\uB9B4\uB808\uC774\uC5D0 \uC5F0\uACB0\uB428 {url}",
|
|
780
|
+
"index.log.loaded": "tunnelbox opencode \uD50C\uB7EC\uADF8\uC778\uC744 \uC2DC\uC791\uD588\uC2B5\uB2C8\uB2E4\uFF08v{version}\uFF09",
|
|
761
781
|
"index.log.disconnected": "\uB9B4\uB808\uC774 \uC5F0\uACB0\uC774 \uB04A\uACA8 \uC790\uB3D9\uC73C\uB85C \uC7AC\uC5F0\uACB0 \uC911\u2026",
|
|
762
782
|
"index.log.exit": "\uC885\uB8CC\uB428",
|
|
763
783
|
"index.log.pairCode": "\uD398\uC5B4\uB9C1 \uCF54\uB4DC \uC0DD\uC131: {code}",
|
|
@@ -908,6 +928,9 @@ var fr_FR_default = {
|
|
|
908
928
|
"agent.log.gotPermReply": "R\xE9ponse d'autorisation re\xE7ue du t\xE9l\xE9phone (id={id} {reply} {version})",
|
|
909
929
|
"agent.log.gotQuestionReply": "R\xE9ponse de question re\xE7ue du t\xE9l\xE9phone (id={id} {status} {version})",
|
|
910
930
|
"agent.log.handleFailed": "\xC9chec du traitement de {type} : {message}",
|
|
931
|
+
"agent.log.msgOk": "R\xE9cup\xE9ration des messages OK session={session} data={count} mode={limited} win={win} ms={ms}",
|
|
932
|
+
"agent.log.msgFailed": "\xC9chec de la r\xE9cup\xE9ration des messages session={session} err={err} ms={ms}",
|
|
933
|
+
"agent.log.msgLimitFallback": "limit non pris en charge, repli sur la r\xE9cup\xE9ration compl\xE8te (session={session})",
|
|
911
934
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
912
935
|
"agent.log.pendingResent": "session.pending : renvoi de {count} demande(s) en attente pour {session}",
|
|
913
936
|
"agent.log.unhandledType": "Type de message non g\xE9r\xE9 : {type}",
|
|
@@ -919,6 +942,7 @@ var fr_FR_default = {
|
|
|
919
942
|
"index.error.pairTimeout": "D\xE9lai d'attente du code d'appairage d\xE9pass\xE9 (le relais ne r\xE9pond pas)",
|
|
920
943
|
"index.log.claimed": "Li\xE9 \xE0 votre compte t\xE9l\xE9phone. Le t\xE9l\xE9phone se connecte d\xE9sormais directement depuis \xAB Mes PC \xBB ; plus besoin de scanner",
|
|
921
944
|
"index.log.connectedRelay": "Connect\xE9 au relais {url}",
|
|
945
|
+
"index.log.loaded": "Plugin tunnelbox opencode d\xE9marr\xE9 (v{version})",
|
|
922
946
|
"index.log.disconnected": "D\xE9connect\xE9 du relais, reconnexion automatique\u2026",
|
|
923
947
|
"index.log.exit": "Arr\xEAt\xE9",
|
|
924
948
|
"index.log.pairCode": "Code d'appairage g\xE9n\xE9r\xE9 : {code}",
|
|
@@ -1069,6 +1093,9 @@ var de_DE_default = {
|
|
|
1069
1093
|
"agent.log.gotPermReply": "Berechtigungsantwort vom Telefon erhalten (id={id} {reply} {version})",
|
|
1070
1094
|
"agent.log.gotQuestionReply": "Frageantwort vom Telefon erhalten (id={id} {status} {version})",
|
|
1071
1095
|
"agent.log.handleFailed": "Fehler beim Verarbeiten von {type}: {message}",
|
|
1096
|
+
"agent.log.msgOk": "Session-Nachrichten OK session={session} data={count} Modus={limited} win={win} ms={ms}",
|
|
1097
|
+
"agent.log.msgFailed": "Session-Nachrichten fehlgeschlagen session={session} err={err} ms={ms}",
|
|
1098
|
+
"agent.log.msgLimitFallback": "limit nicht unterst\xFCtzt, R\xFCckfall auf vollst\xE4ndigen Abruf (session={session})",
|
|
1072
1099
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
1073
1100
|
"agent.log.pendingResent": "session.pending: {count} ausstehende Anfrage(n) f\xFCr {session} erneut gesendet",
|
|
1074
1101
|
"agent.log.unhandledType": "Nicht behandelter Nachrichtentyp: {type}",
|
|
@@ -1080,6 +1107,7 @@ var de_DE_default = {
|
|
|
1080
1107
|
"index.error.pairTimeout": "Zeit\xFCberschreitung beim Warten auf einen Pairing-Code (Relay antwortet nicht)",
|
|
1081
1108
|
"index.log.claimed": "An Ihr Telefonkonto gebunden. Das Telefon verbindet sich nun direkt \xFCber \u201CMeine PCs\u201D; kein erneutes Scannen n\xF6tig",
|
|
1082
1109
|
"index.log.connectedRelay": "Mit Relay verbunden {url}",
|
|
1110
|
+
"index.log.loaded": "tunnelbox-opencode-Plugin gestartet (v{version})",
|
|
1083
1111
|
"index.log.disconnected": "Vom Relay getrennt, verbinde automatisch neu\u2026",
|
|
1084
1112
|
"index.log.exit": "Beendet",
|
|
1085
1113
|
"index.log.pairCode": "Pairing-Code erzeugt: {code}",
|
|
@@ -1230,6 +1258,9 @@ var es_ES_default = {
|
|
|
1230
1258
|
"agent.log.gotPermReply": "Respuesta de permiso recibida del tel\xE9fono (id={id} {reply} {version})",
|
|
1231
1259
|
"agent.log.gotQuestionReply": "Respuesta de pregunta recibida del tel\xE9fono (id={id} {status} {version})",
|
|
1232
1260
|
"agent.log.handleFailed": "Error al procesar {type}: {message}",
|
|
1261
|
+
"agent.log.msgOk": "Mensajes de sesi\xF3n OK session={session} data={count} modo={limited} win={win} ms={ms}",
|
|
1262
|
+
"agent.log.msgFailed": "Error al obtener mensajes de sesi\xF3n session={session} err={err} ms={ms}",
|
|
1263
|
+
"agent.log.msgLimitFallback": "limit no compatible; se vuelve a la obtenci\xF3n completa (session={session})",
|
|
1233
1264
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
1234
1265
|
"agent.log.pendingResent": "session.pending: reenviadas {count} solicitud(es) pendientes para {session}",
|
|
1235
1266
|
"agent.log.unhandledType": "Tipo de mensaje no gestionado: {type}",
|
|
@@ -1241,6 +1272,7 @@ var es_ES_default = {
|
|
|
1241
1272
|
"index.error.pairTimeout": "Tiempo de espera agotado al obtener el c\xF3digo de emparejamiento (el relay no responde)",
|
|
1242
1273
|
"index.log.claimed": "Vinculado a su cuenta de tel\xE9fono. El tel\xE9fono se conecta ahora directamente desde \xABMis PC\xBB; no hace falta volver a escanear",
|
|
1243
1274
|
"index.log.connectedRelay": "Conectado al relay {url}",
|
|
1275
|
+
"index.log.loaded": "Plugin tunnelbox opencode iniciado (v{version})",
|
|
1244
1276
|
"index.log.disconnected": "Desconectado del relay, reconectando autom\xE1ticamente\u2026",
|
|
1245
1277
|
"index.log.exit": "Salido",
|
|
1246
1278
|
"index.log.pairCode": "C\xF3digo de emparejamiento generado: {code}",
|
|
@@ -1550,6 +1582,102 @@ async function printPairing(code, type, name, lang) {
|
|
|
1550
1582
|
console.log(" " + tt("qr.fileWritten", { path: file }));
|
|
1551
1583
|
console.log("");
|
|
1552
1584
|
}
|
|
1585
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
1586
|
+
var MAX_PART_TEXT = 16e3;
|
|
1587
|
+
var MAX_PART_ARGS = 4e3;
|
|
1588
|
+
var MAX_PAGE_BYTES = 15e5;
|
|
1589
|
+
function capStr(s, max) {
|
|
1590
|
+
if (s.length <= max) return s;
|
|
1591
|
+
return `${s.slice(0, max)}\u2026`;
|
|
1592
|
+
}
|
|
1593
|
+
function capMessage(m) {
|
|
1594
|
+
let parts;
|
|
1595
|
+
for (let i = 0; i < m.parts.length; i++) {
|
|
1596
|
+
const p = m.parts[i];
|
|
1597
|
+
const nText = typeof p.text === "string" && p.text.length > MAX_PART_TEXT ? capStr(p.text, MAX_PART_TEXT) : p.text;
|
|
1598
|
+
const nDelta = typeof p.delta === "string" && p.delta.length > MAX_PART_TEXT ? capStr(p.delta, MAX_PART_TEXT) : p.delta;
|
|
1599
|
+
const nArgs = typeof p.args === "string" && p.args.length > MAX_PART_ARGS ? capStr(p.args, MAX_PART_ARGS) : p.args;
|
|
1600
|
+
if (nText !== p.text || nDelta !== p.delta || nArgs !== p.args) {
|
|
1601
|
+
if (!parts) parts = m.parts.slice(0, i);
|
|
1602
|
+
parts.push({ ...p, text: nText, delta: nDelta, args: nArgs });
|
|
1603
|
+
} else if (parts) {
|
|
1604
|
+
parts.push(p);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
return parts ? { ...m, parts } : m;
|
|
1608
|
+
}
|
|
1609
|
+
function capMessages(messages) {
|
|
1610
|
+
let changed = false;
|
|
1611
|
+
const out = messages.map((m) => {
|
|
1612
|
+
const c = capMessage(m);
|
|
1613
|
+
if (c !== m) changed = true;
|
|
1614
|
+
return c;
|
|
1615
|
+
});
|
|
1616
|
+
return changed ? out : messages;
|
|
1617
|
+
}
|
|
1618
|
+
function byteLength(messages) {
|
|
1619
|
+
try {
|
|
1620
|
+
return JSON.stringify(messages).length;
|
|
1621
|
+
} catch {
|
|
1622
|
+
return messages.length * MAX_PART_TEXT * 2;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
function sliceWindow(full, query2 = {}) {
|
|
1626
|
+
const limit = Math.max(1, query2.limit ?? DEFAULT_PAGE_SIZE);
|
|
1627
|
+
const maxBytes = query2.maxBytes ?? MAX_PAGE_BYTES;
|
|
1628
|
+
let end = full.length;
|
|
1629
|
+
if (query2.before !== void 0 && query2.before !== "") {
|
|
1630
|
+
const idx = full.findIndex((m) => m.id === query2.before);
|
|
1631
|
+
if (idx >= 0) end = idx;
|
|
1632
|
+
}
|
|
1633
|
+
let start2 = Math.max(0, end - limit);
|
|
1634
|
+
let messages = full.slice(start2, end);
|
|
1635
|
+
while (messages.length > 1) {
|
|
1636
|
+
const capped = capMessages(messages);
|
|
1637
|
+
if (byteLength(capped) <= maxBytes) {
|
|
1638
|
+
messages = capped;
|
|
1639
|
+
break;
|
|
1640
|
+
}
|
|
1641
|
+
start2++;
|
|
1642
|
+
messages = full.slice(start2, end);
|
|
1643
|
+
}
|
|
1644
|
+
return { messages: capMessages(messages), hasMore: start2 > 0 };
|
|
1645
|
+
}
|
|
1646
|
+
var MessagesCache = class {
|
|
1647
|
+
ttlMs;
|
|
1648
|
+
maxEntries;
|
|
1649
|
+
store = /* @__PURE__ */ new Map();
|
|
1650
|
+
constructor(ttlMs = 2e3, maxEntries = 64) {
|
|
1651
|
+
this.ttlMs = ttlMs;
|
|
1652
|
+
this.maxEntries = maxEntries;
|
|
1653
|
+
}
|
|
1654
|
+
/** 命中且未过 TTL 时返回完整列表副本;否则 undefined。 */
|
|
1655
|
+
get(sessionID, now = Date.now()) {
|
|
1656
|
+
const e = this.store.get(sessionID);
|
|
1657
|
+
if (!e) return void 0;
|
|
1658
|
+
if (now - e.at > this.ttlMs) {
|
|
1659
|
+
this.store.delete(sessionID);
|
|
1660
|
+
return void 0;
|
|
1661
|
+
}
|
|
1662
|
+
return e.full;
|
|
1663
|
+
}
|
|
1664
|
+
put(sessionID, full) {
|
|
1665
|
+
if (this.store.size >= this.maxEntries && !this.store.has(sessionID)) {
|
|
1666
|
+
const oldest = this.store.keys().next().value;
|
|
1667
|
+
if (oldest !== void 0) this.store.delete(oldest);
|
|
1668
|
+
}
|
|
1669
|
+
this.store.set(sessionID, { full, at: Date.now() });
|
|
1670
|
+
}
|
|
1671
|
+
/** 会话内容变化(流式部件/状态/删除等)时调用,立即失效快照。 */
|
|
1672
|
+
invalidate(sessionID) {
|
|
1673
|
+
this.store.delete(sessionID);
|
|
1674
|
+
}
|
|
1675
|
+
/** 适配器重连/整体失效(如清除全部快照)。 */
|
|
1676
|
+
clear() {
|
|
1677
|
+
this.store.clear();
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
var messagesCache = new MessagesCache();
|
|
1553
1681
|
|
|
1554
1682
|
// src/bridge.ts
|
|
1555
1683
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -1983,7 +2111,7 @@ function newSessionId() {
|
|
|
1983
2111
|
}
|
|
1984
2112
|
|
|
1985
2113
|
// src/bridge.ts
|
|
1986
|
-
var VERSION = "0.1.0";
|
|
2114
|
+
var VERSION = true ? "0.1.9" : "0.0.0-dev";
|
|
1987
2115
|
var AGENT_TYPE = "claude-code";
|
|
1988
2116
|
var APPROVAL_TIMEOUT_MS = 12e4;
|
|
1989
2117
|
var ADAPTER_COMMANDS = [
|
|
@@ -2269,13 +2397,13 @@ var ClaudeBridge = class {
|
|
|
2269
2397
|
});
|
|
2270
2398
|
}
|
|
2271
2399
|
async sessionMessages(env) {
|
|
2272
|
-
const { sessionID } = env.payload;
|
|
2400
|
+
const { sessionID, before, limit } = env.payload;
|
|
2273
2401
|
const dir = await this.dirOf(sessionID);
|
|
2274
2402
|
let messages = [];
|
|
2275
2403
|
if (dir && await sessionExists(sessionID, dir)) {
|
|
2276
2404
|
messages = await readHistory(sessionID, dir);
|
|
2277
2405
|
}
|
|
2278
|
-
this.reply(env, "messages", { sessionID, messages });
|
|
2406
|
+
this.reply(env, "messages", { sessionID, ...sliceWindow(messages, { before, limit }) });
|
|
2279
2407
|
}
|
|
2280
2408
|
async sessionPrompt(env) {
|
|
2281
2409
|
const payload = env.payload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tunnelbox/claude-code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "tunnelbox 的 Claude Code 集成(官方 Agent SDK 桥 + 官方插件 official-plugin):手机远程驱动 Claude Code(会话/流式/审批/中止)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"qrcode": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tunnelbox/core": "0.1.
|
|
37
|
+
"@tunnelbox/core": "0.1.9",
|
|
38
38
|
"@types/node": "^22.0.0",
|
|
39
39
|
"@types/qrcode": "^1.5.5",
|
|
40
40
|
"esbuild": "^0.24.0",
|