codeam-cli 1.4.27 → 1.4.29
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.js +102 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ var fs5 = __toESM(require("fs"));
|
|
|
28
28
|
var os5 = __toESM(require("os"));
|
|
29
29
|
var path5 = __toESM(require("path"));
|
|
30
30
|
var import_crypto = require("crypto");
|
|
31
|
+
var import_child_process3 = require("child_process");
|
|
31
32
|
var import_picocolors2 = __toESM(require("picocolors"));
|
|
32
33
|
|
|
33
34
|
// src/config.ts
|
|
@@ -115,7 +116,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
|
|
|
115
116
|
// package.json
|
|
116
117
|
var package_default = {
|
|
117
118
|
name: "codeam-cli",
|
|
118
|
-
version: "1.4.
|
|
119
|
+
version: "1.4.29",
|
|
119
120
|
description: "Remote control Claude Code from your mobile device",
|
|
120
121
|
main: "dist/index.js",
|
|
121
122
|
bin: {
|
|
@@ -1697,30 +1698,110 @@ async function start() {
|
|
|
1697
1698
|
const cwd = process.cwd();
|
|
1698
1699
|
const ws = new WebSocketService(session.id, pluginId);
|
|
1699
1700
|
const historySvc = new HistoryService(pluginId, cwd);
|
|
1700
|
-
let capturingQuota = false;
|
|
1701
|
-
let quotaBuffer = "";
|
|
1702
1701
|
let turnCount = 0;
|
|
1703
1702
|
const USAGE_FETCH_INTERVAL = 5;
|
|
1703
|
+
let quotaFetchInProgress = false;
|
|
1704
1704
|
function fetchQuotaUsage() {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1705
|
+
if (quotaFetchInProgress) return;
|
|
1706
|
+
quotaFetchInProgress = true;
|
|
1707
|
+
const claudeCmd = findInPath("claude") ? "claude" : "claude-code";
|
|
1708
|
+
if (!claudeCmd) {
|
|
1709
|
+
quotaFetchInProgress = false;
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
const helperScript = `import os,pty,sys,select,signal,struct,fcntl,termios,errno
|
|
1713
|
+
m,s=pty.openpty()
|
|
1714
|
+
try:
|
|
1715
|
+
fcntl.ioctl(s,termios.TIOCSWINSZ,struct.pack('HHHH',30,120,0,0))
|
|
1716
|
+
except Exception:pass
|
|
1717
|
+
pid=os.fork()
|
|
1718
|
+
if pid==0:
|
|
1719
|
+
os.close(m);os.setsid()
|
|
1720
|
+
try:fcntl.ioctl(s,termios.TIOCSCTTY,0)
|
|
1721
|
+
except Exception:pass
|
|
1722
|
+
for fd in[0,1,2]:os.dup2(s,fd)
|
|
1723
|
+
if s>2:os.close(s)
|
|
1724
|
+
os.execvp(sys.argv[1],sys.argv[1:])
|
|
1725
|
+
sys.exit(127)
|
|
1726
|
+
os.close(s)
|
|
1727
|
+
done=[False]
|
|
1728
|
+
def onchld(n,f):
|
|
1729
|
+
try:os.waitpid(pid,os.WNOHANG)
|
|
1730
|
+
except Exception:pass
|
|
1731
|
+
done[0]=True
|
|
1732
|
+
signal.signal(signal.SIGCHLD,onchld)
|
|
1733
|
+
i=sys.stdin.fileno();o=sys.stdout.fileno()
|
|
1734
|
+
while not done[0]:
|
|
1735
|
+
try:r,_,_=select.select([i,m],[],[],0.1)
|
|
1736
|
+
except OSError as e:
|
|
1737
|
+
if e.errno==errno.EINTR:continue
|
|
1738
|
+
break
|
|
1739
|
+
if i in r:
|
|
1740
|
+
try:
|
|
1741
|
+
d=os.read(i,4096)
|
|
1742
|
+
if d:os.write(m,d)
|
|
1743
|
+
else:break
|
|
1744
|
+
except OSError:break
|
|
1745
|
+
if m in r:
|
|
1746
|
+
try:
|
|
1747
|
+
d=os.read(m,4096)
|
|
1748
|
+
if d:os.write(o,d)
|
|
1749
|
+
except OSError:done[0]=True
|
|
1750
|
+
try:os.kill(pid,signal.SIGTERM)
|
|
1751
|
+
except Exception:pass
|
|
1752
|
+
try:
|
|
1753
|
+
_,st=os.waitpid(pid,0)
|
|
1754
|
+
sys.exit((st>>8)&0xFF)
|
|
1755
|
+
except Exception:sys.exit(0)
|
|
1756
|
+
`;
|
|
1757
|
+
const helperPath = path5.join(os5.tmpdir(), "codeam-quota-helper.py");
|
|
1758
|
+
fs5.writeFileSync(helperPath, helperScript, { mode: 420 });
|
|
1759
|
+
const python = findInPath("python3") ?? findInPath("python");
|
|
1760
|
+
if (!python) {
|
|
1761
|
+
quotaFetchInProgress = false;
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
const proc = (0, import_child_process3.spawn)(python, [helperPath, claudeCmd, "--tools", ""], {
|
|
1765
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
1766
|
+
cwd: process.cwd(),
|
|
1767
|
+
env: { ...process.env, TERM: "dumb", COLUMNS: "120", LINES: "30" }
|
|
1768
|
+
});
|
|
1769
|
+
let output = "";
|
|
1770
|
+
proc.stdout?.on("data", (chunk) => {
|
|
1771
|
+
output += chunk.toString("utf8");
|
|
1772
|
+
});
|
|
1708
1773
|
setTimeout(() => {
|
|
1709
|
-
|
|
1710
|
-
const weekMatch = clean.match(/current\s+week[^]*?(\d+)%\s*used/i);
|
|
1711
|
-
if (weekMatch) {
|
|
1712
|
-
historySvc.setQuotaPercent(parseInt(weekMatch[1], 10));
|
|
1713
|
-
}
|
|
1714
|
-
const resetMatch = clean.match(/resets\s+(.+?)(?:\s*\(|$)/im);
|
|
1715
|
-
if (resetMatch) {
|
|
1716
|
-
historySvc.setRateLimitReset(resetMatch[1].trim());
|
|
1717
|
-
}
|
|
1718
|
-
claude.sendEscape();
|
|
1774
|
+
proc.stdin?.write("/usage\r");
|
|
1719
1775
|
setTimeout(() => {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1776
|
+
const clean = output.replace(/\x1B\[[^@-~]*[@-~]/g, "").replace(/[\x00-\x1F\x7F]/g, "");
|
|
1777
|
+
const weekMatch = clean.match(/current\s+week[^]*?(\d+)%\s*used/i);
|
|
1778
|
+
if (weekMatch) {
|
|
1779
|
+
historySvc.setQuotaPercent(parseInt(weekMatch[1], 10));
|
|
1780
|
+
}
|
|
1781
|
+
const resetMatch = clean.match(/resets\s+(.+?)(?:\s*\(|$)/im);
|
|
1782
|
+
if (resetMatch) {
|
|
1783
|
+
historySvc.setRateLimitReset(resetMatch[1].trim());
|
|
1784
|
+
}
|
|
1785
|
+
try {
|
|
1786
|
+
proc.kill();
|
|
1787
|
+
} catch {
|
|
1788
|
+
}
|
|
1789
|
+
try {
|
|
1790
|
+
fs5.unlinkSync(helperPath);
|
|
1791
|
+
} catch {
|
|
1792
|
+
}
|
|
1793
|
+
quotaFetchInProgress = false;
|
|
1794
|
+
}, 5e3);
|
|
1795
|
+
}, 8e3);
|
|
1796
|
+
proc.on("exit", () => {
|
|
1797
|
+
quotaFetchInProgress = false;
|
|
1798
|
+
});
|
|
1799
|
+
setTimeout(() => {
|
|
1800
|
+
try {
|
|
1801
|
+
proc.kill();
|
|
1802
|
+
} catch {
|
|
1803
|
+
}
|
|
1804
|
+
}, 2e4);
|
|
1724
1805
|
}
|
|
1725
1806
|
const outputSvc = new OutputService(session.id, pluginId, (conversationId) => {
|
|
1726
1807
|
historySvc.setCurrentConversationId(conversationId);
|
|
@@ -1860,10 +1941,6 @@ async function start() {
|
|
|
1860
1941
|
const claude = new ClaudeService({
|
|
1861
1942
|
cwd: process.cwd(),
|
|
1862
1943
|
onData(raw) {
|
|
1863
|
-
if (capturingQuota) {
|
|
1864
|
-
quotaBuffer += raw;
|
|
1865
|
-
return;
|
|
1866
|
-
}
|
|
1867
1944
|
outputSvc.push(raw);
|
|
1868
1945
|
},
|
|
1869
1946
|
onExit(code) {
|
|
@@ -1890,7 +1967,7 @@ async function start() {
|
|
|
1890
1967
|
}, 2e3);
|
|
1891
1968
|
setTimeout(() => {
|
|
1892
1969
|
fetchQuotaUsage();
|
|
1893
|
-
},
|
|
1970
|
+
}, 5e3);
|
|
1894
1971
|
}
|
|
1895
1972
|
|
|
1896
1973
|
// src/commands/pair.ts
|