clisbot 0.1.19 → 0.1.20

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/main.js +45 -3
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -61890,6 +61890,8 @@ function getExecutableNames(command) {
61890
61890
  // src/runners/tmux/client.ts
61891
61891
  var MAIN_WINDOW_NAME = "main";
61892
61892
  var TMUX_NOT_FOUND_CODE = "ENOENT";
61893
+ var TMUX_SERVER_BOOTSTRAP_TIMEOUT_MS = 1000;
61894
+ var TMUX_SERVER_BOOTSTRAP_POLL_MS = 25;
61893
61895
  var TMUX_SERVER_DEFAULTS = [
61894
61896
  ["exit-empty", "off"],
61895
61897
  ["destroy-unattached", "off"]
@@ -61900,6 +61902,9 @@ class TmuxClient {
61900
61902
  constructor(socketPath) {
61901
61903
  this.socketPath = socketPath;
61902
61904
  }
61905
+ isServerUnavailableOutput(output) {
61906
+ return /no server running|No such file or directory|failed to connect to server|error connecting to/i.test(output);
61907
+ }
61903
61908
  async exec(args, options = {}) {
61904
61909
  if (!commandExists("tmux")) {
61905
61910
  throw new Error("tmux is not installed or not available on PATH. Install tmux and restart clisbot.");
@@ -61951,7 +61956,10 @@ class TmuxClient {
61951
61956
  }
61952
61957
  const output = `${result.stderr}
61953
61958
  ${result.stdout}`.trim();
61954
- return !output.includes("no server running");
61959
+ if (this.isServerUnavailableOutput(output)) {
61960
+ return false;
61961
+ }
61962
+ return false;
61955
61963
  }
61956
61964
  async ensureServerDefaults() {
61957
61965
  if (!await this.isServerRunning()) {
@@ -61961,6 +61969,35 @@ ${result.stdout}`.trim();
61961
61969
  await this.execOrThrow(["set-option", "-g", name, value]);
61962
61970
  }
61963
61971
  }
61972
+ isBootstrapRetryableError(error) {
61973
+ const message = error instanceof Error ? error.message : String(error);
61974
+ return this.isServerUnavailableOutput(message);
61975
+ }
61976
+ async withServerBootstrapRetry(task) {
61977
+ const deadline = Date.now() + TMUX_SERVER_BOOTSTRAP_TIMEOUT_MS;
61978
+ while (true) {
61979
+ try {
61980
+ return await task();
61981
+ } catch (error) {
61982
+ if (!this.isBootstrapRetryableError(error) || Date.now() >= deadline) {
61983
+ throw error;
61984
+ }
61985
+ await sleep(TMUX_SERVER_BOOTSTRAP_POLL_MS);
61986
+ }
61987
+ }
61988
+ }
61989
+ async waitForSessionBootstrap(sessionName) {
61990
+ const deadline = Date.now() + TMUX_SERVER_BOOTSTRAP_TIMEOUT_MS;
61991
+ while (true) {
61992
+ if (await this.hasSession(sessionName)) {
61993
+ return;
61994
+ }
61995
+ if (Date.now() >= deadline) {
61996
+ throw new Error(`tmux session "${sessionName}" did not become reachable on socket ${this.socketPath} within ${TMUX_SERVER_BOOTSTRAP_TIMEOUT_MS}ms.`);
61997
+ }
61998
+ await sleep(TMUX_SERVER_BOOTSTRAP_POLL_MS);
61999
+ }
62000
+ }
61964
62001
  async newSession(params) {
61965
62002
  await this.execOrThrow([
61966
62003
  "new-session",
@@ -61973,8 +62010,13 @@ ${result.stdout}`.trim();
61973
62010
  params.cwd,
61974
62011
  params.command
61975
62012
  ]);
61976
- await this.ensureServerDefaults();
61977
- await this.freezeWindowName(`${params.sessionName}:${MAIN_WINDOW_NAME}`);
62013
+ await this.waitForSessionBootstrap(params.sessionName);
62014
+ await this.withServerBootstrapRetry(async () => {
62015
+ await this.ensureServerDefaults();
62016
+ });
62017
+ await this.withServerBootstrapRetry(async () => {
62018
+ await this.freezeWindowName(`${params.sessionName}:${MAIN_WINDOW_NAME}`);
62019
+ });
61978
62020
  }
61979
62021
  async newWindow(params) {
61980
62022
  const paneId = await this.execOrThrow([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clisbot",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "private": false,
5
5
  "description": "Chat surfaces for durable AI coding agents running in tmux",
6
6
  "license": "MIT",