@tunnelbox/cursor 0.1.7 → 0.1.8
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 +107 -3
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -120,6 +120,7 @@ var zh_CN_default = {
|
|
|
120
120
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5BF9\u7801\u8D85\u65F6\uFF08\u4E2D\u7EE7\u672A\u54CD\u5E94\uFF09",
|
|
121
121
|
"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
122
|
"index.log.connectedRelay": "\u5DF2\u8FDE\u63A5\u4E2D\u7EE7 {url}",
|
|
123
|
+
"index.log.loaded": "tunnelbox opencode \u63D2\u4EF6\u5DF2\u542F\u52A8\uFF08v{version}\uFF09",
|
|
123
124
|
"index.log.disconnected": "\u4E0E\u4E2D\u7EE7\u65AD\u5F00\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8FDE\u2026",
|
|
124
125
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
125
126
|
"index.log.pairCode": "\u751F\u6210\u914D\u5BF9\u7801: {code}",
|
|
@@ -281,6 +282,7 @@ var zh_TW_default = {
|
|
|
281
282
|
"index.error.pairTimeout": "\u7B49\u5F85\u914D\u5C0D\u78BC\u903E\u6642\uFF08\u4E2D\u7E7C\u672A\u56DE\u61C9\uFF09",
|
|
282
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",
|
|
283
284
|
"index.log.connectedRelay": "\u5DF2\u9023\u63A5\u4E2D\u7E7C {url}",
|
|
285
|
+
"index.log.loaded": "tunnelbox opencode \u5916\u639B\u5DF2\u555F\u52D5\uFF08v{version}\uFF09",
|
|
284
286
|
"index.log.disconnected": "\u8207\u4E2D\u7E7C\u65B7\u7DDA\uFF0C\u6B63\u5728\u81EA\u52D5\u91CD\u9023\u2026",
|
|
285
287
|
"index.log.exit": "\u5DF2\u9000\u51FA",
|
|
286
288
|
"index.log.pairCode": "\u7522\u751F\u914D\u5C0D\u78BC: {code}",
|
|
@@ -442,6 +444,7 @@ var en_US_default = {
|
|
|
442
444
|
"index.error.pairTimeout": "Timed out waiting for a pairing code (the relay did not respond)",
|
|
443
445
|
"index.log.claimed": "Bound to your phone account. From now on the phone connects directly from My Computers; no need to scan again",
|
|
444
446
|
"index.log.connectedRelay": "Connected to relay {url}",
|
|
447
|
+
"index.log.loaded": "tunnelbox opencode plugin started (v{version})",
|
|
445
448
|
"index.log.disconnected": "Disconnected from relay, reconnecting automatically\u2026",
|
|
446
449
|
"index.log.exit": "Exited",
|
|
447
450
|
"index.log.pairCode": "Generated pairing code: {code}",
|
|
@@ -603,6 +606,7 @@ var ja_JP_default = {
|
|
|
603
606
|
"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
607
|
"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
608
|
"index.log.connectedRelay": "\u30EA\u30EC\u30FC\u306B\u63A5\u7D9A\u3057\u307E\u3057\u305F {url}",
|
|
609
|
+
"index.log.loaded": "tunnelbox opencode \u30D7\u30E9\u30B0\u30A4\u30F3\u3092\u8D77\u52D5\u3057\u307E\u3057\u305F\uFF08v{version}\uFF09",
|
|
606
610
|
"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
611
|
"index.log.exit": "\u7D42\u4E86\u3057\u307E\u3057\u305F",
|
|
608
612
|
"index.log.pairCode": "\u30DA\u30A2\u30EA\u30F3\u30B0\u30B3\u30FC\u30C9\u3092\u751F\u6210: {code}",
|
|
@@ -764,6 +768,7 @@ var ko_KR_default = {
|
|
|
764
768
|
"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
769
|
"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
770
|
"index.log.connectedRelay": "\uB9B4\uB808\uC774\uC5D0 \uC5F0\uACB0\uB428 {url}",
|
|
771
|
+
"index.log.loaded": "tunnelbox opencode \uD50C\uB7EC\uADF8\uC778\uC744 \uC2DC\uC791\uD588\uC2B5\uB2C8\uB2E4\uFF08v{version}\uFF09",
|
|
767
772
|
"index.log.disconnected": "\uB9B4\uB808\uC774 \uC5F0\uACB0\uC774 \uB04A\uACA8 \uC790\uB3D9\uC73C\uB85C \uC7AC\uC5F0\uACB0 \uC911\u2026",
|
|
768
773
|
"index.log.exit": "\uC885\uB8CC\uB428",
|
|
769
774
|
"index.log.pairCode": "\uD398\uC5B4\uB9C1 \uCF54\uB4DC \uC0DD\uC131: {code}",
|
|
@@ -925,6 +930,7 @@ var fr_FR_default = {
|
|
|
925
930
|
"index.error.pairTimeout": "D\xE9lai d'attente du code d'appairage d\xE9pass\xE9 (le relais ne r\xE9pond pas)",
|
|
926
931
|
"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
932
|
"index.log.connectedRelay": "Connect\xE9 au relais {url}",
|
|
933
|
+
"index.log.loaded": "Plugin tunnelbox opencode d\xE9marr\xE9 (v{version})",
|
|
928
934
|
"index.log.disconnected": "D\xE9connect\xE9 du relais, reconnexion automatique\u2026",
|
|
929
935
|
"index.log.exit": "Arr\xEAt\xE9",
|
|
930
936
|
"index.log.pairCode": "Code d'appairage g\xE9n\xE9r\xE9 : {code}",
|
|
@@ -1086,6 +1092,7 @@ var de_DE_default = {
|
|
|
1086
1092
|
"index.error.pairTimeout": "Zeit\xFCberschreitung beim Warten auf einen Pairing-Code (Relay antwortet nicht)",
|
|
1087
1093
|
"index.log.claimed": "An Ihr Telefonkonto gebunden. Das Telefon verbindet sich nun direkt \xFCber \u201CMeine PCs\u201D; kein erneutes Scannen n\xF6tig",
|
|
1088
1094
|
"index.log.connectedRelay": "Mit Relay verbunden {url}",
|
|
1095
|
+
"index.log.loaded": "tunnelbox-opencode-Plugin gestartet (v{version})",
|
|
1089
1096
|
"index.log.disconnected": "Vom Relay getrennt, verbinde automatisch neu\u2026",
|
|
1090
1097
|
"index.log.exit": "Beendet",
|
|
1091
1098
|
"index.log.pairCode": "Pairing-Code erzeugt: {code}",
|
|
@@ -1247,6 +1254,7 @@ var es_ES_default = {
|
|
|
1247
1254
|
"index.error.pairTimeout": "Tiempo de espera agotado al obtener el c\xF3digo de emparejamiento (el relay no responde)",
|
|
1248
1255
|
"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
1256
|
"index.log.connectedRelay": "Conectado al relay {url}",
|
|
1257
|
+
"index.log.loaded": "Plugin tunnelbox opencode iniciado (v{version})",
|
|
1250
1258
|
"index.log.disconnected": "Desconectado del relay, reconectando autom\xE1ticamente\u2026",
|
|
1251
1259
|
"index.log.exit": "Salido",
|
|
1252
1260
|
"index.log.pairCode": "C\xF3digo de emparejamiento generado: {code}",
|
|
@@ -1553,6 +1561,102 @@ async function printPairing(code, type, name, lang) {
|
|
|
1553
1561
|
console.log(" " + tt("qr.fileWritten", { path: file }));
|
|
1554
1562
|
console.log("");
|
|
1555
1563
|
}
|
|
1564
|
+
var DEFAULT_PAGE_SIZE = 50;
|
|
1565
|
+
var MAX_PART_TEXT = 16e3;
|
|
1566
|
+
var MAX_PART_ARGS = 4e3;
|
|
1567
|
+
var MAX_PAGE_BYTES = 15e5;
|
|
1568
|
+
function capStr(s, max) {
|
|
1569
|
+
if (s.length <= max) return s;
|
|
1570
|
+
return `${s.slice(0, max)}\u2026`;
|
|
1571
|
+
}
|
|
1572
|
+
function capMessage(m) {
|
|
1573
|
+
let parts;
|
|
1574
|
+
for (let i = 0; i < m.parts.length; i++) {
|
|
1575
|
+
const p = m.parts[i];
|
|
1576
|
+
const nText = typeof p.text === "string" && p.text.length > MAX_PART_TEXT ? capStr(p.text, MAX_PART_TEXT) : p.text;
|
|
1577
|
+
const nDelta = typeof p.delta === "string" && p.delta.length > MAX_PART_TEXT ? capStr(p.delta, MAX_PART_TEXT) : p.delta;
|
|
1578
|
+
const nArgs = typeof p.args === "string" && p.args.length > MAX_PART_ARGS ? capStr(p.args, MAX_PART_ARGS) : p.args;
|
|
1579
|
+
if (nText !== p.text || nDelta !== p.delta || nArgs !== p.args) {
|
|
1580
|
+
if (!parts) parts = m.parts.slice(0, i);
|
|
1581
|
+
parts.push({ ...p, text: nText, delta: nDelta, args: nArgs });
|
|
1582
|
+
} else if (parts) {
|
|
1583
|
+
parts.push(p);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
return parts ? { ...m, parts } : m;
|
|
1587
|
+
}
|
|
1588
|
+
function capMessages(messages) {
|
|
1589
|
+
let changed = false;
|
|
1590
|
+
const out = messages.map((m) => {
|
|
1591
|
+
const c = capMessage(m);
|
|
1592
|
+
if (c !== m) changed = true;
|
|
1593
|
+
return c;
|
|
1594
|
+
});
|
|
1595
|
+
return changed ? out : messages;
|
|
1596
|
+
}
|
|
1597
|
+
function byteLength(messages) {
|
|
1598
|
+
try {
|
|
1599
|
+
return JSON.stringify(messages).length;
|
|
1600
|
+
} catch {
|
|
1601
|
+
return messages.length * MAX_PART_TEXT * 2;
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
function sliceWindow(full, query = {}) {
|
|
1605
|
+
const limit = Math.max(1, query.limit ?? DEFAULT_PAGE_SIZE);
|
|
1606
|
+
const maxBytes = query.maxBytes ?? MAX_PAGE_BYTES;
|
|
1607
|
+
let end = full.length;
|
|
1608
|
+
if (query.before !== void 0 && query.before !== "") {
|
|
1609
|
+
const idx = full.findIndex((m) => m.id === query.before);
|
|
1610
|
+
if (idx >= 0) end = idx;
|
|
1611
|
+
}
|
|
1612
|
+
let start2 = Math.max(0, end - limit);
|
|
1613
|
+
let messages = full.slice(start2, end);
|
|
1614
|
+
while (messages.length > 1) {
|
|
1615
|
+
const capped = capMessages(messages);
|
|
1616
|
+
if (byteLength(capped) <= maxBytes) {
|
|
1617
|
+
messages = capped;
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
start2++;
|
|
1621
|
+
messages = full.slice(start2, end);
|
|
1622
|
+
}
|
|
1623
|
+
return { messages: capMessages(messages), hasMore: start2 > 0 };
|
|
1624
|
+
}
|
|
1625
|
+
var MessagesCache = class {
|
|
1626
|
+
ttlMs;
|
|
1627
|
+
maxEntries;
|
|
1628
|
+
store = /* @__PURE__ */ new Map();
|
|
1629
|
+
constructor(ttlMs = 2e3, maxEntries = 64) {
|
|
1630
|
+
this.ttlMs = ttlMs;
|
|
1631
|
+
this.maxEntries = maxEntries;
|
|
1632
|
+
}
|
|
1633
|
+
/** 命中且未过 TTL 时返回完整列表副本;否则 undefined。 */
|
|
1634
|
+
get(sessionID, now = Date.now()) {
|
|
1635
|
+
const e = this.store.get(sessionID);
|
|
1636
|
+
if (!e) return void 0;
|
|
1637
|
+
if (now - e.at > this.ttlMs) {
|
|
1638
|
+
this.store.delete(sessionID);
|
|
1639
|
+
return void 0;
|
|
1640
|
+
}
|
|
1641
|
+
return e.full;
|
|
1642
|
+
}
|
|
1643
|
+
put(sessionID, full) {
|
|
1644
|
+
if (this.store.size >= this.maxEntries && !this.store.has(sessionID)) {
|
|
1645
|
+
const oldest = this.store.keys().next().value;
|
|
1646
|
+
if (oldest !== void 0) this.store.delete(oldest);
|
|
1647
|
+
}
|
|
1648
|
+
this.store.set(sessionID, { full, at: Date.now() });
|
|
1649
|
+
}
|
|
1650
|
+
/** 会话内容变化(流式部件/状态/删除等)时调用,立即失效快照。 */
|
|
1651
|
+
invalidate(sessionID) {
|
|
1652
|
+
this.store.delete(sessionID);
|
|
1653
|
+
}
|
|
1654
|
+
/** 适配器重连/整体失效(如清除全部快照)。 */
|
|
1655
|
+
clear() {
|
|
1656
|
+
this.store.clear();
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
var messagesCache = new MessagesCache();
|
|
1556
1660
|
|
|
1557
1661
|
// src/runner.ts
|
|
1558
1662
|
import { spawn } from "node:child_process";
|
|
@@ -1905,7 +2009,7 @@ async function removeSession(sessionID) {
|
|
|
1905
2009
|
}
|
|
1906
2010
|
|
|
1907
2011
|
// src/bridge.ts
|
|
1908
|
-
var VERSION = "0.1.0";
|
|
2012
|
+
var VERSION = true ? "0.1.8" : "0.0.0-dev";
|
|
1909
2013
|
var AGENT_TYPE = "cursor";
|
|
1910
2014
|
var ADAPTER_COMMANDS = [
|
|
1911
2015
|
{ name: "new", description: "\u65B0\u5EFA\u4F1A\u8BDD" },
|
|
@@ -2068,9 +2172,9 @@ var CursorBridge = class {
|
|
|
2068
2172
|
});
|
|
2069
2173
|
}
|
|
2070
2174
|
async sessionMessages(env) {
|
|
2071
|
-
const { sessionID } = env.payload;
|
|
2175
|
+
const { sessionID, before, limit } = env.payload;
|
|
2072
2176
|
const messages = exists(sessionID) ? await readHistory(sessionID) : [];
|
|
2073
|
-
this.reply(env, "messages", { sessionID, messages });
|
|
2177
|
+
this.reply(env, "messages", { sessionID, ...sliceWindow(messages, { before, limit }) });
|
|
2074
2178
|
}
|
|
2075
2179
|
async sessionPrompt(env) {
|
|
2076
2180
|
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.8",
|
|
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.8",
|
|
35
35
|
"@types/node": "^22.0.0",
|
|
36
36
|
"@types/qrcode": "^1.5.5",
|
|
37
37
|
"esbuild": "^0.24.0",
|