@tunnelbox/cursor 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
|
@@ -109,6 +109,9 @@ var zh_CN_default = {
|
|
|
109
109
|
"agent.log.gotPermReply": "\u6536\u5230\u624B\u673A\u6743\u9650\u56DE\u590D (id={id} {reply} {version})",
|
|
110
110
|
"agent.log.gotQuestionReply": "\u6536\u5230\u624B\u673A\u63D0\u95EE\u56DE\u590D (id={id} {status} {version})",
|
|
111
111
|
"agent.log.handleFailed": "\u5904\u7406 {type} \u5931\u8D25: {message}",
|
|
112
|
+
"agent.log.msgOk": "\u62C9\u53D6\u4F1A\u8BDD\u6D88\u606F\u6210\u529F session={session} data={count} \u65B9\u5F0F={limited} win={win} ms={ms}",
|
|
113
|
+
"agent.log.msgFailed": "\u62C9\u53D6\u4F1A\u8BDD\u6D88\u606F\u5931\u8D25 session={session} err={err} ms={ms}",
|
|
114
|
+
"agent.log.msgLimitFallback": "\u5F53\u524D opencode \u4E0D\u652F\u6301 limit\uFF0C\u56DE\u9000\u5168\u91CF\u62C9\u53D6\uFF08session={session}\uFF09",
|
|
112
115
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
113
116
|
"agent.log.pendingResent": "session.pending: \u8865\u53D1 {session} \u79EF\u538B\u8BF7\u6C42 {count} \u6761",
|
|
114
117
|
"agent.log.unhandledType": "\u672A\u5904\u7406\u7684\u6D88\u606F\u7C7B\u578B: {type}",
|
|
@@ -120,6 +123,7 @@ var zh_CN_default = {
|
|
|
120
123
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5BF9\u7801\u8D85\u65F6\uFF08\u4E2D\u7EE7\u672A\u54CD\u5E94\uFF09",
|
|
121
124
|
"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",
|
|
122
125
|
"index.log.connectedRelay": "\u5DF2\u8FDE\u63A5\u4E2D\u7EE7 {url}",
|
|
126
|
+
"index.log.loaded": "tunnelbox opencode \u63D2\u4EF6\u5DF2\u542F\u52A8\uFF08v{version}\uFF09",
|
|
123
127
|
"index.log.disconnected": "\u4E0E\u4E2D\u7EE7\u65AD\u5F00\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8FDE\u2026",
|
|
124
128
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
125
129
|
"index.log.pairCode": "\u751F\u6210\u914D\u5BF9\u7801: {code}",
|
|
@@ -270,6 +274,9 @@ var zh_TW_default = {
|
|
|
270
274
|
"agent.log.gotPermReply": "\u6536\u5230\u624B\u6A5F\u6B0A\u9650\u56DE\u8986 (id={id} {reply} {version})",
|
|
271
275
|
"agent.log.gotQuestionReply": "\u6536\u5230\u624B\u6A5F\u63D0\u554F\u56DE\u8986 (id={id} {status} {version})",
|
|
272
276
|
"agent.log.handleFailed": "\u8655\u7406 {type} \u5931\u6557: {message}",
|
|
277
|
+
"agent.log.msgOk": "\u53D6\u5F97\u6703\u8A71\u8A0A\u606F\u6210\u529F session={session} data={count} \u65B9\u5F0F={limited} win={win} ms={ms}",
|
|
278
|
+
"agent.log.msgFailed": "\u53D6\u5F97\u6703\u8A71\u8A0A\u606F\u5931\u6557 session={session} err={err} ms={ms}",
|
|
279
|
+
"agent.log.msgLimitFallback": "\u76EE\u524D\u7684 opencode \u4E0D\u652F\u63F4 limit\uFF0C\u6539\u70BA\u5168\u91CF\u53D6\u5F97\uFF08session={session}\uFF09",
|
|
273
280
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
274
281
|
"agent.log.pendingResent": "session.pending: \u88DC\u767C {session} \u7A4D\u58D3\u8ACB\u6C42 {count} \u689D",
|
|
275
282
|
"agent.log.unhandledType": "\u672A\u8655\u7406\u7684\u8A0A\u606F\u985E\u578B: {type}",
|
|
@@ -281,6 +288,7 @@ var zh_TW_default = {
|
|
|
281
288
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5C0D\u78BC\u903E\u6642\uFF08\u4E2D\u7E7C\u672A\u56DE\u61C9\uFF09",
|
|
282
289
|
"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",
|
|
283
290
|
"index.log.connectedRelay": "\u5DF2\u9023\u63A5\u4E2D\u7E7C {url}",
|
|
291
|
+
"index.log.loaded": "tunnelbox opencode \u5916\u639B\u5DF2\u555F\u52D5\uFF08v{version}\uFF09",
|
|
284
292
|
"index.log.disconnected": "\u8207\u4E2D\u7E7C\u65B7\u7DDA\uFF0C\u6B63\u5728\u81EA\u52D5\u91CD\u9023\u2026",
|
|
285
293
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
286
294
|
"index.log.pairCode": "\u7522\u751F\u914D\u5C0D\u78BC: {code}",
|
|
@@ -431,6 +439,9 @@ var en_US_default = {
|
|
|
431
439
|
"agent.log.gotPermReply": "Received permission reply from phone (id={id} {reply} {version})",
|
|
432
440
|
"agent.log.gotQuestionReply": "Received question reply from phone (id={id} {status} {version})",
|
|
433
441
|
"agent.log.handleFailed": "Failed to handle {type}: {message}",
|
|
442
|
+
"agent.log.msgOk": "session.messages OK session={session} data={count} limited={limited} win={win} ms={ms}",
|
|
443
|
+
"agent.log.msgFailed": "session.messages FAILED session={session} err={err} ms={ms}",
|
|
444
|
+
"agent.log.msgLimitFallback": "limit unsupported, fell back to full session fetch (session={session})",
|
|
434
445
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
435
446
|
"agent.log.pendingResent": "session.pending: resent {count} pending request(s) for {session}",
|
|
436
447
|
"agent.log.unhandledType": "Unhandled message type: {type}",
|
|
@@ -442,6 +453,7 @@ var en_US_default = {
|
|
|
442
453
|
"index.error.pairTimeout": "Timed out waiting for a pairing code (the relay did not respond)",
|
|
443
454
|
"index.log.claimed": "Bound to your phone account. From now on the phone connects directly from My Computers; no need to scan again",
|
|
444
455
|
"index.log.connectedRelay": "Connected to relay {url}",
|
|
456
|
+
"index.log.loaded": "tunnelbox opencode plugin started (v{version})",
|
|
445
457
|
"index.log.disconnected": "Disconnected from relay, reconnecting automatically\u2026",
|
|
446
458
|
"index.log.exit": "Exited",
|
|
447
459
|
"index.log.pairCode": "Generated pairing code: {code}",
|
|
@@ -592,6 +604,9 @@ var ja_JP_default = {
|
|
|
592
604
|
"agent.log.gotPermReply": "\u643A\u5E2F\u304B\u3089\u6A29\u9650\u306E\u8FD4\u4FE1\u3092\u53D7\u4FE1 (id={id} {reply} {version})",
|
|
593
605
|
"agent.log.gotQuestionReply": "\u643A\u5E2F\u304B\u3089\u8CEA\u554F\u306E\u8FD4\u4FE1\u3092\u53D7\u4FE1 (id={id} {status} {version})",
|
|
594
606
|
"agent.log.handleFailed": "{type} \u306E\u51E6\u7406\u306B\u5931\u6557: {message}",
|
|
607
|
+
"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}",
|
|
608
|
+
"agent.log.msgFailed": "\u30BB\u30C3\u30B7\u30E7\u30F3\u30E1\u30C3\u30BB\u30FC\u30B8\u53D6\u5F97\u5931\u6557 session={session} err={err} ms={ms}",
|
|
609
|
+
"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",
|
|
595
610
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
596
611
|
"agent.log.pendingResent": "session.pending: {session} \u306E\u4FDD\u7559\u30EA\u30AF\u30A8\u30B9\u30C8 {count} \u4EF6\u3092\u518D\u9001",
|
|
597
612
|
"agent.log.unhandledType": "\u672A\u51E6\u7406\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u30BF\u30A4\u30D7: {type}",
|
|
@@ -603,6 +618,7 @@ var ja_JP_default = {
|
|
|
603
618
|
"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",
|
|
604
619
|
"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",
|
|
605
620
|
"index.log.connectedRelay": "\u30EA\u30EC\u30FC\u306B\u63A5\u7D9A\u3057\u307E\u3057\u305F {url}",
|
|
621
|
+
"index.log.loaded": "tunnelbox opencode \u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u8D77\u52D5\u3057\u307E\u3057\u305F\uFF08v{version}\uFF09",
|
|
606
622
|
"index.log.disconnected": "\u30EA\u30EC\u30FC\u304B\u3089\u5207\u65AD\u3001\u81EA\u52D5\u7684\u306B\u518D\u63A5\u7D9A\u3057\u3066\u3044\u307E\u3059\u2026",
|
|
607
623
|
"index.log.exit": "\u7D42\u4E86\u3057\u307E\u3057\u305F",
|
|
608
624
|
"index.log.pairCode": "\u30DA\u30A2\u30EA\u30F3\u30B0\u30B3\u30FC\u30C9\u3092\u751F\u6210: {code}",
|
|
@@ -753,6 +769,9 @@ var ko_KR_default = {
|
|
|
753
769
|
"agent.log.gotPermReply": "\uD734\uB300\uD3F0\uC5D0\uC11C \uAD8C\uD55C \uC751\uB2F5 \uC218\uC2E0 (id={id} {reply} {version})",
|
|
754
770
|
"agent.log.gotQuestionReply": "\uD734\uB300\uD3F0\uC5D0\uC11C \uC9C8\uBB38 \uC751\uB2F5 \uC218\uC2E0 (id={id} {status} {version})",
|
|
755
771
|
"agent.log.handleFailed": "{type} \uCC98\uB9AC \uC2E4\uD328: {message}",
|
|
772
|
+
"agent.log.msgOk": "\uC138\uC158 \uBA54\uC2DC\uC9C0 \uC870\uD68C \uC131\uACF5 session={session} data={count} \uBC29\uC2DD={limited} win={win} ms={ms}",
|
|
773
|
+
"agent.log.msgFailed": "\uC138\uC158 \uBA54\uC2DC\uC9C0 \uC870\uD68C \uC2E4\uD328 session={session} err={err} ms={ms}",
|
|
774
|
+
"agent.log.msgLimitFallback": "\uC774 opencode\uB294 limit \uBBF8\uC9C0\uC6D0 \u2192 \uC804\uCCB4 \uC870\uD68C\uB85C \uD3F4\uBC31 (session={session})",
|
|
756
775
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
757
776
|
"agent.log.pendingResent": "session.pending: {session} \uBCF4\uB958 \uC694\uCCAD {count}\uAC74 \uC7AC\uC804\uC1A1",
|
|
758
777
|
"agent.log.unhandledType": "\uCC98\uB9AC\uB418\uC9C0 \uC54A\uC740 \uBA54\uC2DC\uC9C0 \uC720\uD615: {type}",
|
|
@@ -764,6 +783,7 @@ var ko_KR_default = {
|
|
|
764
783
|
"index.error.pairTimeout": "\uD398\uC5B4\uB9C1 \uCF54\uB4DC \uB300\uAE30 \uC2DC\uAC04 \uCD08\uACFC(\uB9B4\uB808\uC774\uAC00 \uC751\uB2F5\uD558\uC9C0 \uC54A\uC74C)",
|
|
765
784
|
"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",
|
|
766
785
|
"index.log.connectedRelay": "\uB9B4\uB808\uC774\uC5D0 \uC5F0\uACB0\uB428 {url}",
|
|
786
|
+
"index.log.loaded": "tunnelbox opencode \uD50C\uB7EC\uADF8\uC778\uC744 \uC2DC\uC791\uD588\uC2B5\uB2C8\uB2E4\uFF08v{version}\uFF09",
|
|
767
787
|
"index.log.disconnected": "\uB9B4\uB808\uC774 \uC5F0\uACB0\uC774 \uB04A\uACA8 \uC790\uB3D9\uC73C\uB85C \uC7AC\uC5F0\uACB0 \uC911\u2026",
|
|
768
788
|
"index.log.exit": "\uC885\uB8CC\uB428",
|
|
769
789
|
"index.log.pairCode": "\uD398\uC5B4\uB9C1 \uCF54\uB4DC \uC0DD\uC131: {code}",
|
|
@@ -914,6 +934,9 @@ var fr_FR_default = {
|
|
|
914
934
|
"agent.log.gotPermReply": "R\xE9ponse d'autorisation re\xE7ue du t\xE9l\xE9phone (id={id} {reply} {version})",
|
|
915
935
|
"agent.log.gotQuestionReply": "R\xE9ponse de question re\xE7ue du t\xE9l\xE9phone (id={id} {status} {version})",
|
|
916
936
|
"agent.log.handleFailed": "\xC9chec du traitement de {type} : {message}",
|
|
937
|
+
"agent.log.msgOk": "R\xE9cup\xE9ration des messages OK session={session} data={count} mode={limited} win={win} ms={ms}",
|
|
938
|
+
"agent.log.msgFailed": "\xC9chec de la r\xE9cup\xE9ration des messages session={session} err={err} ms={ms}",
|
|
939
|
+
"agent.log.msgLimitFallback": "limit non pris en charge, repli sur la r\xE9cup\xE9ration compl\xE8te (session={session})",
|
|
917
940
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
918
941
|
"agent.log.pendingResent": "session.pending : renvoi de {count} demande(s) en attente pour {session}",
|
|
919
942
|
"agent.log.unhandledType": "Type de message non g\xE9r\xE9 : {type}",
|
|
@@ -925,6 +948,7 @@ var fr_FR_default = {
|
|
|
925
948
|
"index.error.pairTimeout": "D\xE9lai d'attente du code d'appairage d\xE9pass\xE9 (le relais ne r\xE9pond pas)",
|
|
926
949
|
"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",
|
|
927
950
|
"index.log.connectedRelay": "Connect\xE9 au relais {url}",
|
|
951
|
+
"index.log.loaded": "Plugin tunnelbox opencode d\xE9marr\xE9 (v{version})",
|
|
928
952
|
"index.log.disconnected": "D\xE9connect\xE9 du relais, reconnexion automatique\u2026",
|
|
929
953
|
"index.log.exit": "Arr\xEAt\xE9",
|
|
930
954
|
"index.log.pairCode": "Code d'appairage g\xE9n\xE9r\xE9 : {code}",
|
|
@@ -1075,6 +1099,9 @@ var de_DE_default = {
|
|
|
1075
1099
|
"agent.log.gotPermReply": "Berechtigungsantwort vom Telefon erhalten (id={id} {reply} {version})",
|
|
1076
1100
|
"agent.log.gotQuestionReply": "Frageantwort vom Telefon erhalten (id={id} {status} {version})",
|
|
1077
1101
|
"agent.log.handleFailed": "Fehler beim Verarbeiten von {type}: {message}",
|
|
1102
|
+
"agent.log.msgOk": "Session-Nachrichten OK session={session} data={count} Modus={limited} win={win} ms={ms}",
|
|
1103
|
+
"agent.log.msgFailed": "Session-Nachrichten fehlgeschlagen session={session} err={err} ms={ms}",
|
|
1104
|
+
"agent.log.msgLimitFallback": "limit nicht unterst\xFCtzt, R\xFCckfall auf vollst\xE4ndigen Abruf (session={session})",
|
|
1078
1105
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
1079
1106
|
"agent.log.pendingResent": "session.pending: {count} ausstehende Anfrage(n) f\xFCr {session} erneut gesendet",
|
|
1080
1107
|
"agent.log.unhandledType": "Nicht behandelter Nachrichtentyp: {type}",
|
|
@@ -1086,6 +1113,7 @@ var de_DE_default = {
|
|
|
1086
1113
|
"index.error.pairTimeout": "Zeit\xFCberschreitung beim Warten auf einen Pairing-Code (Relay antwortet nicht)",
|
|
1087
1114
|
"index.log.claimed": "An Ihr Telefonkonto gebunden. Das Telefon verbindet sich nun direkt \xFCber \u201CMeine PCs\u201D; kein erneutes Scannen n\xF6tig",
|
|
1088
1115
|
"index.log.connectedRelay": "Mit Relay verbunden {url}",
|
|
1116
|
+
"index.log.loaded": "tunnelbox-opencode-Plugin gestartet (v{version})",
|
|
1089
1117
|
"index.log.disconnected": "Vom Relay getrennt, verbinde automatisch neu\u2026",
|
|
1090
1118
|
"index.log.exit": "Beendet",
|
|
1091
1119
|
"index.log.pairCode": "Pairing-Code erzeugt: {code}",
|
|
@@ -1236,6 +1264,9 @@ var es_ES_default = {
|
|
|
1236
1264
|
"agent.log.gotPermReply": "Respuesta de permiso recibida del tel\xE9fono (id={id} {reply} {version})",
|
|
1237
1265
|
"agent.log.gotQuestionReply": "Respuesta de pregunta recibida del tel\xE9fono (id={id} {status} {version})",
|
|
1238
1266
|
"agent.log.handleFailed": "Error al procesar {type}: {message}",
|
|
1267
|
+
"agent.log.msgOk": "Mensajes de sesi\xF3n OK session={session} data={count} modo={limited} win={win} ms={ms}",
|
|
1268
|
+
"agent.log.msgFailed": "Error al obtener mensajes de sesi\xF3n session={session} err={err} ms={ms}",
|
|
1269
|
+
"agent.log.msgLimitFallback": "limit no compatible; se vuelve a la obtenci\xF3n completa (session={session})",
|
|
1239
1270
|
"agent.log.httpOk": "opencode HTTP {status} {path}",
|
|
1240
1271
|
"agent.log.pendingResent": "session.pending: reenviadas {count} solicitud(es) pendientes para {session}",
|
|
1241
1272
|
"agent.log.unhandledType": "Tipo de mensaje no gestionado: {type}",
|
|
@@ -1247,6 +1278,7 @@ var es_ES_default = {
|
|
|
1247
1278
|
"index.error.pairTimeout": "Tiempo de espera agotado al obtener el c\xF3digo de emparejamiento (el relay no responde)",
|
|
1248
1279
|
"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",
|
|
1249
1280
|
"index.log.connectedRelay": "Conectado al relay {url}",
|
|
1281
|
+
"index.log.loaded": "Plugin tunnelbox opencode iniciado (v{version})",
|
|
1250
1282
|
"index.log.disconnected": "Desconectado del relay, reconectando autom\xE1ticamente\u2026",
|
|
1251
1283
|
"index.log.exit": "Salido",
|
|
1252
1284
|
"index.log.pairCode": "C\xF3digo de emparejamiento generado: {code}",
|
|
@@ -1553,6 +1585,102 @@ async function printPairing(code, type, name, lang) {
|
|
|
1553
1585
|
console.log(" " + tt("qr.fileWritten", { path: file }));
|
|
1554
1586
|
console.log("");
|
|
1555
1587
|
}
|
|
1588
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
1589
|
+
var MAX_PART_TEXT = 16e3;
|
|
1590
|
+
var MAX_PART_ARGS = 4e3;
|
|
1591
|
+
var MAX_PAGE_BYTES = 15e5;
|
|
1592
|
+
function capStr(s, max) {
|
|
1593
|
+
if (s.length <= max) return s;
|
|
1594
|
+
return `${s.slice(0, max)}\u2026`;
|
|
1595
|
+
}
|
|
1596
|
+
function capMessage(m) {
|
|
1597
|
+
let parts;
|
|
1598
|
+
for (let i = 0; i < m.parts.length; i++) {
|
|
1599
|
+
const p = m.parts[i];
|
|
1600
|
+
const nText = typeof p.text === "string" && p.text.length > MAX_PART_TEXT ? capStr(p.text, MAX_PART_TEXT) : p.text;
|
|
1601
|
+
const nDelta = typeof p.delta === "string" && p.delta.length > MAX_PART_TEXT ? capStr(p.delta, MAX_PART_TEXT) : p.delta;
|
|
1602
|
+
const nArgs = typeof p.args === "string" && p.args.length > MAX_PART_ARGS ? capStr(p.args, MAX_PART_ARGS) : p.args;
|
|
1603
|
+
if (nText !== p.text || nDelta !== p.delta || nArgs !== p.args) {
|
|
1604
|
+
if (!parts) parts = m.parts.slice(0, i);
|
|
1605
|
+
parts.push({ ...p, text: nText, delta: nDelta, args: nArgs });
|
|
1606
|
+
} else if (parts) {
|
|
1607
|
+
parts.push(p);
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
return parts ? { ...m, parts } : m;
|
|
1611
|
+
}
|
|
1612
|
+
function capMessages(messages) {
|
|
1613
|
+
let changed = false;
|
|
1614
|
+
const out = messages.map((m) => {
|
|
1615
|
+
const c = capMessage(m);
|
|
1616
|
+
if (c !== m) changed = true;
|
|
1617
|
+
return c;
|
|
1618
|
+
});
|
|
1619
|
+
return changed ? out : messages;
|
|
1620
|
+
}
|
|
1621
|
+
function byteLength(messages) {
|
|
1622
|
+
try {
|
|
1623
|
+
return JSON.stringify(messages).length;
|
|
1624
|
+
} catch {
|
|
1625
|
+
return messages.length * MAX_PART_TEXT * 2;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
function sliceWindow(full, query = {}) {
|
|
1629
|
+
const limit = Math.max(1, query.limit ?? DEFAULT_PAGE_SIZE);
|
|
1630
|
+
const maxBytes = query.maxBytes ?? MAX_PAGE_BYTES;
|
|
1631
|
+
let end = full.length;
|
|
1632
|
+
if (query.before !== void 0 && query.before !== "") {
|
|
1633
|
+
const idx = full.findIndex((m) => m.id === query.before);
|
|
1634
|
+
if (idx >= 0) end = idx;
|
|
1635
|
+
}
|
|
1636
|
+
let start2 = Math.max(0, end - limit);
|
|
1637
|
+
let messages = full.slice(start2, end);
|
|
1638
|
+
while (messages.length > 1) {
|
|
1639
|
+
const capped = capMessages(messages);
|
|
1640
|
+
if (byteLength(capped) <= maxBytes) {
|
|
1641
|
+
messages = capped;
|
|
1642
|
+
break;
|
|
1643
|
+
}
|
|
1644
|
+
start2++;
|
|
1645
|
+
messages = full.slice(start2, end);
|
|
1646
|
+
}
|
|
1647
|
+
return { messages: capMessages(messages), hasMore: start2 > 0 };
|
|
1648
|
+
}
|
|
1649
|
+
var MessagesCache = class {
|
|
1650
|
+
ttlMs;
|
|
1651
|
+
maxEntries;
|
|
1652
|
+
store = /* @__PURE__ */ new Map();
|
|
1653
|
+
constructor(ttlMs = 2e3, maxEntries = 64) {
|
|
1654
|
+
this.ttlMs = ttlMs;
|
|
1655
|
+
this.maxEntries = maxEntries;
|
|
1656
|
+
}
|
|
1657
|
+
/** 命中且未过 TTL 时返回完整列表副本;否则 undefined。 */
|
|
1658
|
+
get(sessionID, now = Date.now()) {
|
|
1659
|
+
const e = this.store.get(sessionID);
|
|
1660
|
+
if (!e) return void 0;
|
|
1661
|
+
if (now - e.at > this.ttlMs) {
|
|
1662
|
+
this.store.delete(sessionID);
|
|
1663
|
+
return void 0;
|
|
1664
|
+
}
|
|
1665
|
+
return e.full;
|
|
1666
|
+
}
|
|
1667
|
+
put(sessionID, full) {
|
|
1668
|
+
if (this.store.size >= this.maxEntries && !this.store.has(sessionID)) {
|
|
1669
|
+
const oldest = this.store.keys().next().value;
|
|
1670
|
+
if (oldest !== void 0) this.store.delete(oldest);
|
|
1671
|
+
}
|
|
1672
|
+
this.store.set(sessionID, { full, at: Date.now() });
|
|
1673
|
+
}
|
|
1674
|
+
/** 会话内容变化(流式部件/状态/删除等)时调用,立即失效快照。 */
|
|
1675
|
+
invalidate(sessionID) {
|
|
1676
|
+
this.store.delete(sessionID);
|
|
1677
|
+
}
|
|
1678
|
+
/** 适配器重连/整体失效(如清除全部快照)。 */
|
|
1679
|
+
clear() {
|
|
1680
|
+
this.store.clear();
|
|
1681
|
+
}
|
|
1682
|
+
};
|
|
1683
|
+
var messagesCache = new MessagesCache();
|
|
1556
1684
|
|
|
1557
1685
|
// src/runner.ts
|
|
1558
1686
|
import { spawn } from "node:child_process";
|
|
@@ -1905,7 +2033,7 @@ async function removeSession(sessionID) {
|
|
|
1905
2033
|
}
|
|
1906
2034
|
|
|
1907
2035
|
// src/bridge.ts
|
|
1908
|
-
var VERSION = "0.1.0";
|
|
2036
|
+
var VERSION = true ? "0.1.9" : "0.0.0-dev";
|
|
1909
2037
|
var AGENT_TYPE = "cursor";
|
|
1910
2038
|
var ADAPTER_COMMANDS = [
|
|
1911
2039
|
{ name: "new", description: "\u65B0\u5EFA\u4F1A\u8BDD" },
|
|
@@ -2068,9 +2196,9 @@ var CursorBridge = class {
|
|
|
2068
2196
|
});
|
|
2069
2197
|
}
|
|
2070
2198
|
async sessionMessages(env) {
|
|
2071
|
-
const { sessionID } = env.payload;
|
|
2199
|
+
const { sessionID, before, limit } = env.payload;
|
|
2072
2200
|
const messages = exists(sessionID) ? await readHistory(sessionID) : [];
|
|
2073
|
-
this.reply(env, "messages", { sessionID, messages });
|
|
2201
|
+
this.reply(env, "messages", { sessionID, ...sliceWindow(messages, { before, limit }) });
|
|
2074
2202
|
}
|
|
2075
2203
|
async sessionPrompt(env) {
|
|
2076
2204
|
const payload = env.payload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tunnelbox/cursor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "tunnelbox 的 Cursor 适配器(C 类/B2 头less):手机远程驱动本机 Cursor CLI(agent -p stream-json,会话/流式/中止/删除)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"qrcode": "^1.5.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tunnelbox/core": "0.1.
|
|
34
|
+
"@tunnelbox/core": "0.1.9",
|
|
35
35
|
"@types/node": "^22.0.0",
|
|
36
36
|
"@types/qrcode": "^1.5.5",
|
|
37
37
|
"esbuild": "^0.24.0",
|