muuuuse 2.2.2 → 2.2.4

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/package.json +1 -1
  2. package/src/runtime.js +15 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muuuuse",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "🔌Muuuuse arms two regular terminals and relays assistant output between them.",
5
5
  "type": "commonjs",
6
6
  "bin": {
package/src/runtime.js CHANGED
@@ -35,9 +35,8 @@ const {
35
35
  writeJson,
36
36
  } = require("./util");
37
37
 
38
- const TYPE_CHUNK_DELAY_MS = 12;
39
- const TYPE_CHUNK_SIZE = 6;
40
- const ESCAPE_RELAY_GUARD_MS = 180;
38
+ const TYPE_CHUNK_DELAY_MS = 18;
39
+ const TYPE_CHUNK_SIZE = 24;
41
40
  const MIRROR_SUPPRESSION_WINDOW_MS = 30 * 1000;
42
41
  const PENDING_RELAY_CONTEXT_TTL_MS = 2 * 60 * 1000;
43
42
  const EMITTED_ANSWER_TTL_MS = 5 * 60 * 1000;
@@ -479,19 +478,6 @@ function isMeaningfulTerminalInput(input) {
479
478
  return stripPassiveTerminalInput(input).length > 0;
480
479
  }
481
480
 
482
- function getEscapeRelayDelayMs(lastEscapeAtMs, now = Date.now()) {
483
- if (!Number.isFinite(lastEscapeAtMs) || lastEscapeAtMs <= 0) {
484
- return 0;
485
- }
486
-
487
- const elapsedMs = now - lastEscapeAtMs;
488
- if (elapsedMs >= ESCAPE_RELAY_GUARD_MS) {
489
- return 0;
490
- }
491
-
492
- return ESCAPE_RELAY_GUARD_MS - elapsedMs;
493
- }
494
-
495
481
  async function sendTextAndEnter(child, text, shouldAbort = () => false) {
496
482
  const payload = normalizeRelayPayloadForTyping(text);
497
483
 
@@ -551,7 +537,6 @@ class ArmedSeat {
551
537
  this.forceKillTimer = null;
552
538
  this.identity = null;
553
539
  this.lastUserInputAtMs = 0;
554
- this.lastEscapeAtMs = 0;
555
540
  this.pendingInboundContext = null;
556
541
  this.recentInboundRelays = [];
557
542
  this.recentEmittedAnswers = [];
@@ -829,9 +814,6 @@ class ArmedSeat {
829
814
  installStdinProxy() {
830
815
  const handleData = (chunk) => {
831
816
  const chunkText = chunk.toString("utf8");
832
- if (isBareEscapeInput(chunkText)) {
833
- this.lastEscapeAtMs = Date.now();
834
- }
835
817
  if (isMeaningfulTerminalInput(chunkText)) {
836
818
  this.lastUserInputAtMs = Date.now();
837
819
  this.pendingInboundContext = null;
@@ -950,6 +932,12 @@ class ArmedSeat {
950
932
  return Boolean(partner?.pid && isPidAlive(partner.pid));
951
933
  }
952
934
 
935
+ getPartnerFlowMode() {
936
+ const partnerStatus = readJson(this.partnerPaths.statusPath, null);
937
+ const partnerMeta = readJson(this.partnerPaths.metaPath, null);
938
+ return normalizeFlowMode(partnerStatus?.flowMode || partnerMeta?.flowMode || "off");
939
+ }
940
+
953
941
  stopRequested() {
954
942
  const request = readJson(this.sessionPaths.stopPath, null);
955
943
  if (!request?.requestedAt) {
@@ -994,11 +982,6 @@ class ArmedSeat {
994
982
  continue;
995
983
  }
996
984
 
997
- const escapeRelayDelayMs = getEscapeRelayDelayMs(this.lastEscapeAtMs);
998
- if (escapeRelayDelayMs > 0) {
999
- await sleep(escapeRelayDelayMs);
1000
- }
1001
-
1002
985
  const delivered = await sendTextAndEnter(
1003
986
  this.child,
1004
987
  payload,
@@ -1275,7 +1258,13 @@ class ArmedSeat {
1275
1258
  }
1276
1259
 
1277
1260
  const pendingInboundContext = this.getPendingInboundContext();
1278
- if (this.flowMode !== "on" && pendingInboundContext && pendingInboundContext.hop >= MAX_RELAY_CHAIN_HOP) {
1261
+ const partnerFlowMode = this.getPartnerFlowMode();
1262
+ if (
1263
+ this.flowMode !== "on" &&
1264
+ partnerFlowMode !== "on" &&
1265
+ pendingInboundContext &&
1266
+ pendingInboundContext.hop >= MAX_RELAY_CHAIN_HOP
1267
+ ) {
1279
1268
  this.log(`[${this.seatId}] suppressed relay loop: ${previewText(payload)}`);
1280
1269
  return;
1281
1270
  }
@@ -1543,7 +1532,6 @@ module.exports = {
1543
1532
  ArmedSeat,
1544
1533
  buildChildEnv,
1545
1534
  chunkRelayPayloadForTyping,
1546
- getEscapeRelayDelayMs,
1547
1535
  getStatusReport,
1548
1536
  isBareEscapeInput,
1549
1537
  isMeaningfulTerminalInput,