codeam-cli 1.1.0 → 1.1.1
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 +46 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ var import_picocolors = __toESM(require("picocolors"));
|
|
|
110
110
|
// package.json
|
|
111
111
|
var package_default = {
|
|
112
112
|
name: "codeam-cli",
|
|
113
|
-
version: "1.1.
|
|
113
|
+
version: "1.1.1",
|
|
114
114
|
description: "Remote control Claude Code from your mobile device",
|
|
115
115
|
main: "dist/index.js",
|
|
116
116
|
bin: {
|
|
@@ -745,19 +745,20 @@ var OutputService = class _OutputService {
|
|
|
745
745
|
}
|
|
746
746
|
sessionId;
|
|
747
747
|
pluginId;
|
|
748
|
-
// Buffer that accumulates PTY text (ANSI stripped, growing during response)
|
|
749
748
|
buffer = "";
|
|
750
749
|
lastSentBuffer = "";
|
|
751
|
-
stableCount = 0;
|
|
752
750
|
pollTimer = null;
|
|
753
751
|
startTime = 0;
|
|
754
752
|
active = false;
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
static
|
|
758
|
-
|
|
759
|
-
static
|
|
753
|
+
/** Time since last meaningful push() — when this exceeds IDLE_MS, response is done. */
|
|
754
|
+
lastPushTime = 0;
|
|
755
|
+
static POLL_MS = 500;
|
|
756
|
+
/** No new content for 3 s = Claude finished responding. */
|
|
757
|
+
static IDLE_MS = 3e3;
|
|
758
|
+
/** No content at all for 30 s = give up (connection issue, etc.). */
|
|
760
759
|
static EMPTY_TIMEOUT_MS = 3e4;
|
|
760
|
+
/** Hard cap — always clear typing state after 2 minutes. */
|
|
761
|
+
static MAX_MS = 12e4;
|
|
761
762
|
/**
|
|
762
763
|
* Call before sending a command from mobile.
|
|
763
764
|
* Clears previous output, sends new_turn event, starts polling.
|
|
@@ -766,52 +767,49 @@ var OutputService = class _OutputService {
|
|
|
766
767
|
this.stopPoll();
|
|
767
768
|
this.buffer = "";
|
|
768
769
|
this.lastSentBuffer = "";
|
|
769
|
-
this.
|
|
770
|
+
this.lastPushTime = 0;
|
|
770
771
|
this.active = true;
|
|
771
772
|
this.startTime = Date.now();
|
|
772
773
|
this.postChunk({ clear: true }).then(() => this.postChunk({ type: "new_turn", content: "", done: false })).catch(() => {
|
|
773
774
|
});
|
|
774
|
-
this.pollTimer = setInterval(() => this.
|
|
775
|
+
this.pollTimer = setInterval(() => this.tick(), _OutputService.POLL_MS);
|
|
775
776
|
}
|
|
776
777
|
/** Feed raw terminal output from Claude (called on every stdout chunk). */
|
|
777
778
|
push(raw) {
|
|
778
779
|
if (!this.active) return;
|
|
779
780
|
const text = stripAnsi(raw).replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n");
|
|
780
|
-
if (text)
|
|
781
|
+
if (text.trim()) {
|
|
782
|
+
this.buffer += text;
|
|
783
|
+
this.lastPushTime = Date.now();
|
|
784
|
+
}
|
|
781
785
|
}
|
|
782
786
|
dispose() {
|
|
783
787
|
this.stopPoll();
|
|
784
788
|
this.active = false;
|
|
785
789
|
}
|
|
786
|
-
|
|
787
|
-
* Stability check — runs every POLL_MS while active.
|
|
788
|
-
*
|
|
789
|
-
* Only finalises when we have content that has stopped changing.
|
|
790
|
-
* This avoids premature done signals while Claude is still thinking
|
|
791
|
-
* (which would set active=false and silently drop the real response).
|
|
792
|
-
*/
|
|
793
|
-
checkStability() {
|
|
790
|
+
tick() {
|
|
794
791
|
if (!this.active) return;
|
|
795
|
-
|
|
792
|
+
const now = Date.now();
|
|
793
|
+
const elapsed = now - this.startTime;
|
|
794
|
+
if (elapsed >= _OutputService.MAX_MS) {
|
|
796
795
|
this.finalize();
|
|
797
796
|
return;
|
|
798
797
|
}
|
|
799
|
-
const
|
|
800
|
-
if (!
|
|
801
|
-
if (
|
|
798
|
+
const hasContent = this.buffer.trim().length > 0;
|
|
799
|
+
if (!hasContent) {
|
|
800
|
+
if (elapsed >= _OutputService.EMPTY_TIMEOUT_MS) {
|
|
802
801
|
this.finalize();
|
|
803
802
|
}
|
|
804
803
|
return;
|
|
805
804
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
this.
|
|
813
|
-
this.
|
|
814
|
-
this.postChunk({ type: "text", content: current, done: false }).catch(() => {
|
|
805
|
+
const idleMs = this.lastPushTime > 0 ? now - this.lastPushTime : elapsed;
|
|
806
|
+
if (idleMs >= _OutputService.IDLE_MS) {
|
|
807
|
+
this.finalize();
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (this.buffer !== this.lastSentBuffer) {
|
|
811
|
+
this.lastSentBuffer = this.buffer;
|
|
812
|
+
this.postChunk({ type: "text", content: this.buffer, done: false }).catch(() => {
|
|
815
813
|
});
|
|
816
814
|
}
|
|
817
815
|
}
|
|
@@ -850,11 +848,24 @@ var OutputService = class _OutputService {
|
|
|
850
848
|
timeout: 8e3
|
|
851
849
|
},
|
|
852
850
|
(res) => {
|
|
853
|
-
|
|
854
|
-
|
|
851
|
+
let body2 = "";
|
|
852
|
+
res.on("data", (c) => {
|
|
853
|
+
body2 += c.toString();
|
|
854
|
+
});
|
|
855
|
+
res.on("end", () => {
|
|
856
|
+
if (res.statusCode && res.statusCode >= 400) {
|
|
857
|
+
process.stderr.write(`[codeam] output API error ${res.statusCode}: ${body2}
|
|
858
|
+
`);
|
|
859
|
+
}
|
|
860
|
+
resolve();
|
|
861
|
+
});
|
|
855
862
|
}
|
|
856
863
|
);
|
|
857
|
-
req.on("error", () =>
|
|
864
|
+
req.on("error", (err) => {
|
|
865
|
+
process.stderr.write(`[codeam] output POST failed: ${err.message}
|
|
866
|
+
`);
|
|
867
|
+
resolve();
|
|
868
|
+
});
|
|
858
869
|
req.on("timeout", () => {
|
|
859
870
|
req.destroy();
|
|
860
871
|
resolve();
|