codeam-cli 1.4.41 → 1.4.43

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.
Files changed (2) hide show
  1. package/dist/index.js +64 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ var import_qrcode_terminal = __toESM(require("qrcode-terminal"));
116
116
  // package.json
117
117
  var package_default = {
118
118
  name: "codeam-cli",
119
- version: "1.4.41",
119
+ version: "1.4.43",
120
120
  description: "Remote control Claude Code from your mobile device",
121
121
  main: "dist/index.js",
122
122
  bin: {
@@ -1143,12 +1143,13 @@ function filterChrome(lines) {
1143
1143
  return result;
1144
1144
  }
1145
1145
  var OutputService = class _OutputService {
1146
- constructor(sessionId, pluginId, onSessionIdDetected, onRateLimitDetected, onTurnComplete) {
1146
+ constructor(sessionId, pluginId, onSessionIdDetected, onRateLimitDetected, onTurnComplete, onTerminalTurnDetected) {
1147
1147
  this.sessionId = sessionId;
1148
1148
  this.pluginId = pluginId;
1149
1149
  this.onSessionIdDetected = onSessionIdDetected;
1150
1150
  this.onRateLimitDetected = onRateLimitDetected;
1151
1151
  this.onTurnComplete = onTurnComplete;
1152
+ this.onTerminalTurnDetected = onTerminalTurnDetected;
1152
1153
  }
1153
1154
  sessionId;
1154
1155
  pluginId;
@@ -1157,10 +1158,12 @@ var OutputService = class _OutputService {
1157
1158
  pollTimer = null;
1158
1159
  startTime = 0;
1159
1160
  active = false;
1161
+ terminalTurnPending = false;
1160
1162
  lastPushTime = 0;
1161
1163
  onSessionIdDetected;
1162
1164
  onRateLimitDetected;
1163
1165
  onTurnComplete;
1166
+ onTerminalTurnDetected;
1164
1167
  static POLL_MS = 1e3;
1165
1168
  static IDLE_MS = 3e3;
1166
1169
  /** Shorter idle threshold for selector detection (UI is ready immediately). */
@@ -1175,12 +1178,22 @@ var OutputService = class _OutputService {
1175
1178
  /** Max idle with no visible content (spinner only) before finalizing. */
1176
1179
  static EMPTY_TIMEOUT_MS = 6e4;
1177
1180
  static MAX_MS = 12e4;
1181
+ /** Called by the terminal-turn callback after posting the user message. */
1182
+ startTerminalTurn() {
1183
+ this.terminalTurnPending = false;
1184
+ this.newTurn();
1185
+ }
1186
+ /** Post a user_message chunk so apps display what was typed in the terminal. */
1187
+ postUserMessage(text) {
1188
+ return this.postChunk({ type: "user_message", content: text, done: true });
1189
+ }
1178
1190
  newTurn() {
1179
1191
  this.stopPoll();
1180
1192
  this.rawBuffer = "";
1181
1193
  this.lastSentContent = "";
1182
1194
  this.lastPushTime = 0;
1183
1195
  this.active = true;
1196
+ this.terminalTurnPending = false;
1184
1197
  this.startTime = Date.now();
1185
1198
  this.postChunk({ clear: true }).then(() => this.postChunk({ type: "new_turn", content: "", done: false })).catch(() => {
1186
1199
  });
@@ -1203,7 +1216,16 @@ var OutputService = class _OutputService {
1203
1216
  this.pollTimer = setInterval(() => this.tick(), _OutputService.POLL_MS);
1204
1217
  }
1205
1218
  push(raw) {
1206
- if (!this.active) return;
1219
+ if (!this.active) {
1220
+ if (!this.terminalTurnPending) {
1221
+ const printable2 = raw.replace(/\x1B\[[^@-~]*[@-~]/g, "").replace(/[\x00-\x1F\x7F]/g, "");
1222
+ if (printable2.trim()) {
1223
+ this.terminalTurnPending = true;
1224
+ this.onTerminalTurnDetected?.();
1225
+ }
1226
+ }
1227
+ return;
1228
+ }
1207
1229
  this.rawBuffer += raw;
1208
1230
  const printable = raw.replace(/\x1B\[[^@-~]*[@-~]/g, "").replace(/[\x00-\x1F\x7F]/g, "");
1209
1231
  if (printable.trim()) {
@@ -1493,6 +1515,16 @@ var HistoryService = class {
1493
1515
  getCurrentConversationId() {
1494
1516
  return this.currentConversationId;
1495
1517
  }
1518
+ /** Return the text of the last user message in the current conversation, or null. */
1519
+ getLastUserMessage() {
1520
+ if (!this.currentConversationId) return null;
1521
+ const filePath = path4.join(this.projectDir, `${this.currentConversationId}.jsonl`);
1522
+ const messages = parseJsonl(filePath);
1523
+ for (let i = messages.length - 1; i >= 0; i--) {
1524
+ if (messages[i].role === "user") return messages[i].text;
1525
+ }
1526
+ return null;
1527
+ }
1496
1528
  /** Detect the active conversation by finding the most recently modified JSONL file */
1497
1529
  detectCurrentConversation() {
1498
1530
  const dir = this.projectDir;
@@ -1853,11 +1885,15 @@ except Exception:sys.exit(0)
1853
1885
  if (historySvc.isQuotaStale()) {
1854
1886
  fetchQuotaUsage();
1855
1887
  }
1856
- const currentId = historySvc.getCurrentConversationId();
1857
- if (currentId) {
1858
- historySvc.loadConversation(currentId).catch(() => {
1859
- });
1860
- }
1888
+ }, () => {
1889
+ setTimeout(async () => {
1890
+ const userText = historySvc.getLastUserMessage();
1891
+ if (userText) {
1892
+ await outputSvc.postUserMessage(userText).catch(() => {
1893
+ });
1894
+ }
1895
+ outputSvc.startTerminalTurn();
1896
+ }, 300);
1861
1897
  });
1862
1898
  function sendPrompt(prompt) {
1863
1899
  outputSvc.newTurn();
@@ -1926,6 +1962,20 @@ except Exception:sys.exit(0)
1926
1962
  claude.restart(id, auto);
1927
1963
  break;
1928
1964
  }
1965
+ case "get_conversation": {
1966
+ const currentId = historySvc.getCurrentConversationId();
1967
+ if (currentId) {
1968
+ try {
1969
+ await historySvc.loadConversation(currentId);
1970
+ await relay.sendResult(cmd.id, "completed", { conversationId: currentId });
1971
+ } catch {
1972
+ await relay.sendResult(cmd.id, "failed", {});
1973
+ }
1974
+ } else {
1975
+ await relay.sendResult(cmd.id, "completed", { conversationId: null });
1976
+ }
1977
+ break;
1978
+ }
1929
1979
  }
1930
1980
  });
1931
1981
  ws.addHandler({
@@ -1970,6 +2020,12 @@ except Exception:sys.exit(0)
1970
2020
  claude.sendEscape();
1971
2021
  } else if (cmdType === "stop_task") {
1972
2022
  claude.interrupt();
2023
+ } else if (cmdType === "get_conversation") {
2024
+ const currentId = historySvc.getCurrentConversationId();
2025
+ if (currentId) {
2026
+ historySvc.loadConversation(currentId).catch(() => {
2027
+ });
2028
+ }
1973
2029
  } else if (cmdType === "resume_session") {
1974
2030
  const id = inner.id;
1975
2031
  const auto = inner.auto ?? false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeam-cli",
3
- "version": "1.4.41",
3
+ "version": "1.4.43",
4
4
  "description": "Remote control Claude Code from your mobile device",
5
5
  "main": "dist/index.js",
6
6
  "bin": {