@staff0rd/assist 0.1092.0 → 0.1092.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 CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.1092.0",
9
+ version: "0.1092.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -1898,9 +1898,6 @@ function isExtensionOrigin(origin) {
1898
1898
  return !!origin && EXTENSION_ORIGIN.test(origin);
1899
1899
  }
1900
1900
 
1901
- // src/commands/sessions/web/handleSocket.ts
1902
- import { createInterface } from "readline";
1903
-
1904
1901
  // src/commands/sessions/daemon/links/isLinkCreate.ts
1905
1902
  var CREATE_TYPES = /* @__PURE__ */ new Set([
1906
1903
  "create",
@@ -1954,6 +1951,46 @@ function resolveNodeName() {
1954
1951
  return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
1955
1952
  }
1956
1953
 
1954
+ // src/commands/sessions/web/forEachCompleteLine.ts
1955
+ import { StringDecoder } from "string_decoder";
1956
+ function forEachCompleteLine(input, onLine, onTruncated) {
1957
+ const decoder = new StringDecoder("utf8");
1958
+ let buffered = "";
1959
+ input.on("data", (chunk2) => {
1960
+ const searchFrom = buffered.length;
1961
+ buffered += typeof chunk2 === "string" ? chunk2 : decoder.write(chunk2);
1962
+ let lineStart = 0;
1963
+ let newline = buffered.indexOf("\n", searchFrom);
1964
+ while (newline !== -1) {
1965
+ const line = buffered.slice(lineStart, newline);
1966
+ onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
1967
+ lineStart = newline + 1;
1968
+ newline = buffered.indexOf("\n", lineStart);
1969
+ }
1970
+ buffered = buffered.slice(lineStart);
1971
+ });
1972
+ const flushTruncated = () => {
1973
+ const partial = buffered + decoder.end();
1974
+ buffered = "";
1975
+ if (partial) onTruncated(partial);
1976
+ };
1977
+ input.on("end", flushTruncated);
1978
+ input.on("close", flushTruncated);
1979
+ }
1980
+
1981
+ // src/commands/sessions/web/withRepoCwd.ts
1982
+ function withRepoCwd(line, repoCwd) {
1983
+ if (!repoCwd) return line;
1984
+ try {
1985
+ const data = JSON.parse(line);
1986
+ if (data.type !== "sessions" || data.cwd) return line;
1987
+ data.cwd = repoCwd;
1988
+ return JSON.stringify(data);
1989
+ } catch {
1990
+ return line;
1991
+ }
1992
+ }
1993
+
1957
1994
  // src/commands/sessions/web/handleSocket.ts
1958
1995
  var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
1959
1996
  function handleSocket(ws, ctx) {
@@ -1982,12 +2019,15 @@ async function openDaemonConnection(ws, ctx) {
1982
2019
  }
1983
2020
  }
1984
2021
  function relayDaemonLines(conn, ws, repoCwd) {
1985
- const lines = createInterface({ input: conn });
1986
- lines.on("error", () => {
1987
- });
1988
- lines.on("line", (line) => {
1989
- if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
1990
- });
2022
+ forEachCompleteLine(
2023
+ conn,
2024
+ (line) => {
2025
+ if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
2026
+ },
2027
+ (partial) => console.log(
2028
+ `ws relay: dropped truncated daemon message (${partial.length} chars) after the daemon connection closed`
2029
+ )
2030
+ );
1991
2031
  conn.on("error", () => {
1992
2032
  });
1993
2033
  conn.on("close", () => ws.close());
@@ -2016,17 +2056,6 @@ function withDefaultCwd(raw, serverCwd) {
2016
2056
  function targetsLinkedNode(data) {
2017
2057
  return resolveLinkTarget(data, resolveNodeName(), () => true).kind !== "local";
2018
2058
  }
2019
- function withRepoCwd(line, repoCwd) {
2020
- if (!repoCwd) return line;
2021
- try {
2022
- const data = JSON.parse(line);
2023
- if (data.type !== "sessions" || data.cwd) return line;
2024
- data.cwd = repoCwd;
2025
- return JSON.stringify(data);
2026
- } catch {
2027
- return line;
2028
- }
2029
- }
2030
2059
 
2031
2060
  // src/commands/sessions/web/isAppOrigin.ts
2032
2061
  var APP_ORIGIN = "capacitor://localhost";
@@ -5307,7 +5336,7 @@ function recordPromptJournal(entry) {
5307
5336
  }
5308
5337
 
5309
5338
  // src/commands/sessions/daemon/requestDaemonReply.ts
5310
- import { createInterface as createInterface2 } from "readline";
5339
+ import { createInterface } from "readline";
5311
5340
  var QUERY_TIMEOUT_MS = 3e3;
5312
5341
  async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_MS) {
5313
5342
  let socket;
@@ -5323,7 +5352,7 @@ async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_
5323
5352
  resolve34(result);
5324
5353
  };
5325
5354
  const timer = setTimeout(() => finish2(void 0), timeoutMs);
5326
- const lines = createInterface2({ input: socket });
5355
+ const lines = createInterface({ input: socket });
5327
5356
  lines.on("error", () => {
5328
5357
  });
5329
5358
  lines.on("line", (line) => {
@@ -14698,7 +14727,7 @@ function installRestartMenu(options2 = {}) {
14698
14727
  }
14699
14728
 
14700
14729
  // src/commands/sessions/web/streamDaemonLogs.ts
14701
- import { createInterface as createInterface4 } from "readline";
14730
+ import { createInterface as createInterface3 } from "readline";
14702
14731
  var RECONNECT_MS = 3e3;
14703
14732
  function streamDaemonLogs() {
14704
14733
  void connect2();
@@ -14717,7 +14746,7 @@ async function connect2() {
14717
14746
  }
14718
14747
  }
14719
14748
  function wire(socket) {
14720
- const lines = createInterface4({ input: socket });
14749
+ const lines = createInterface3({ input: socket });
14721
14750
  lines.on("error", () => {
14722
14751
  });
14723
14752
  lines.on("line", emit);
@@ -50730,7 +50759,7 @@ function listDaemonPids() {
50730
50759
  }
50731
50760
 
50732
50761
  // src/commands/sessions/daemon/queryDaemon.ts
50733
- import { createInterface as createInterface8 } from "readline";
50762
+ import { createInterface as createInterface7 } from "readline";
50734
50763
  var STATUS_TIMEOUT_MS2 = 5e3;
50735
50764
  function queryDaemon(socket) {
50736
50765
  socket.write(`${JSON.stringify({ type: "ping" })}
@@ -50739,7 +50768,7 @@ function queryDaemon(socket) {
50739
50768
  const result = { sessions: [] };
50740
50769
  const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
50741
50770
  const timer = setTimeout(() => resolve34(result), STATUS_TIMEOUT_MS2);
50742
- const lines = createInterface8({ input: socket });
50771
+ const lines = createInterface7({ input: socket });
50743
50772
  lines.on("error", () => {
50744
50773
  });
50745
50774
  lines.on("line", (line) => {
@@ -50833,7 +50862,7 @@ function reportStrays(pids) {
50833
50862
  }
50834
50863
 
50835
50864
  // src/commands/sessions/daemon/drainDaemon.ts
50836
- import { createInterface as createInterface9 } from "readline";
50865
+ import { createInterface as createInterface8 } from "readline";
50837
50866
 
50838
50867
  // src/commands/sessions/daemon/clearPersistedSessionsOnDrain.ts
50839
50868
  function clearPersistedSessionsOnDrain() {
@@ -50875,7 +50904,7 @@ async function drainDaemon(options2 = {}) {
50875
50904
  clearPersistedSessionsOnDrain();
50876
50905
  return;
50877
50906
  }
50878
- const lines = createInterface9({ input: socket });
50907
+ const lines = createInterface8({ input: socket });
50879
50908
  lines.on("error", () => {
50880
50909
  });
50881
50910
  const live = await liveSessions(lines);
@@ -58547,7 +58576,7 @@ function exitAfterFlush(code) {
58547
58576
  }
58548
58577
 
58549
58578
  // src/commands/sessions/daemon/handleConnection.ts
58550
- import { createInterface as createInterface11 } from "readline";
58579
+ import { createInterface as createInterface10 } from "readline";
58551
58580
 
58552
58581
  // src/commands/sessions/daemon/routed.ts
58553
58582
  function routed(local) {
@@ -59811,7 +59840,7 @@ function handleConnection(socket, manager) {
59811
59840
  };
59812
59841
  manager.addClient(client);
59813
59842
  manager.clients.greet(client);
59814
- const lines = createInterface11({ input: socket });
59843
+ const lines = createInterface10({ input: socket });
59815
59844
  lines.on("error", () => {
59816
59845
  });
59817
59846
  lines.on("line", (line) => {
@@ -60462,14 +60491,14 @@ function registerNodes(sessions) {
60462
60491
  }
60463
60492
 
60464
60493
  // src/commands/sessions/daemon/requestSessionOutput.ts
60465
- import { createInterface as createInterface12 } from "readline";
60494
+ import { createInterface as createInterface11 } from "readline";
60466
60495
  var OUTPUT_TIMEOUT_MS = 5e3;
60467
60496
  async function requestSessionOutput(target) {
60468
60497
  const socket = await connectToDaemon().catch(() => {
60469
60498
  throw new Error("No sessions daemon is running");
60470
60499
  });
60471
60500
  try {
60472
- const lines = createInterface12({ input: socket });
60501
+ const lines = createInterface11({ input: socket });
60473
60502
  lines.on("error", () => {
60474
60503
  });
60475
60504
  const reply2 = readDaemonMessage(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1092.0",
3
+ "version": "0.1092.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {