@threadbase-sh/streamer 1.55.3 → 1.56.0

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.cjs CHANGED
@@ -516,6 +516,12 @@ var FEATURE_FLAGS = [
516
516
  default: false,
517
517
  env: "THREADBASE_FEATURE_LIVE_ACTIVITY_PUSH"
518
518
  },
519
+ {
520
+ id: "e2ee",
521
+ description: "Application-layer encryption between a paired device and this server, independent of TLS, so a tunnel or a LAN observer on the path carries ciphertext. Off by default: it is negotiated per device, never forced, because released mobile builds cannot be force-updated and a server that demanded it would break every one of them.",
522
+ default: false,
523
+ env: "THREADBASE_FEATURE_E2EE"
524
+ },
519
525
  {
520
526
  id: "ptyHost",
521
527
  description: "Keep live PTYs in a separate host process so a streamer restart can reconnect without restarting the agents. Off by default until cross-platform behavior is qualified.",
@@ -1049,6 +1055,7 @@ var import_headless = require("@xterm/headless");
1049
1055
  var PTY_COLS = 120;
1050
1056
  var PTY_ROWS = 40;
1051
1057
  var SCREEN_SCROLLBACK = 1e3;
1058
+ var REPLAY_MAX_LINES = SCREEN_SCROLLBACK + PTY_ROWS;
1052
1059
  function digestBytes(s) {
1053
1060
  const escaped = s.replace(new RegExp(String.fromCharCode(27), "g"), "\\x1b").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
1054
1061
  if (escaped.length <= 200) return escaped;
@@ -5786,6 +5793,25 @@ function describePushCapability(liveActivityEnabled, env = process.env) {
5786
5793
  liveActivityReason: describeMissingApnsCredentials(env) ?? "APNs credentials are set but the push token store is unavailable, so Live Activity push is disabled."
5787
5794
  };
5788
5795
  }
5796
+ var E2EE_PROTOCOL_VERSION = 1;
5797
+ var E2EE_SUPPORTED = false;
5798
+ function describeE2eeCapability(flagEnabled) {
5799
+ const enabled = E2EE_SUPPORTED && flagEnabled;
5800
+ const base = {
5801
+ supported: E2EE_SUPPORTED,
5802
+ enabled,
5803
+ version: E2EE_PROTOCOL_VERSION,
5804
+ required: false
5805
+ };
5806
+ if (enabled) return base;
5807
+ return {
5808
+ ...base,
5809
+ // Always says why, including when `supported` is false. An operator who set
5810
+ // the flag and saw nothing happen has exactly one question, and a field that
5811
+ // goes absent in the case they hit is the field not answering it.
5812
+ reason: E2EE_SUPPORTED ? "disabled by the e2ee feature flag \u2014 set THREADBASE_FEATURE_E2EE=1, --feature e2ee=true, or feature_flags: in server.yaml" : "this build carries the capability negotiation but not yet the handshake it gates"
5813
+ };
5814
+ }
5789
5815
  var identityKeyFailureLogged = false;
5790
5816
  function describeServerIdentityKey() {
5791
5817
  try {
@@ -5840,7 +5866,11 @@ var createMiscRoutes = (deps) => {
5840
5866
  // learn it without re-scanning. Additive: absent means a server with no
5841
5867
  // readable identity key, which a client must read as "cannot verify this
5842
5868
  // server" — never as a reason to fail the rest of this response.
5843
- serverIdentityKey: describeServerIdentityKey()
5869
+ serverIdentityKey: describeServerIdentityKey(),
5870
+ // Whether to encrypt to this server. Additive, same contract as `push`:
5871
+ // absent means an older server, which a client must read as "unknown" and
5872
+ // resolve as today's plaintext path — never as a reason to fail.
5873
+ e2ee: describeE2eeCapability(deps.featureFlagsConfig().values.e2ee)
5844
5874
  });
5845
5875
  });
5846
5876
  app.get("/api/profiles", (c) => c.json([]));
@@ -12358,7 +12388,7 @@ function createApiDeps(deps) {
12358
12388
  }
12359
12389
  deps.addSessionSubscriber(msg.sessionId, ws);
12360
12390
  if (deps.ptyManager.hasSession(msg.sessionId)) {
12361
- const lines = await deps.ptyManager.getOutputLines(msg.sessionId, 200);
12391
+ const lines = await deps.ptyManager.getOutputLines(msg.sessionId, REPLAY_MAX_LINES);
12362
12392
  const userMessages = deps.ptyManager.getInputHistory(msg.sessionId);
12363
12393
  ws.send(
12364
12394
  JSON.stringify({