tmex-cli 0.2.3 → 0.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.
@@ -4,42 +4,61 @@ var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
7
10
  var __reExport = (target, mod, secondTarget) => {
8
- for (let key of __getOwnPropNames(mod))
11
+ var keys = __getOwnPropNames(mod);
12
+ for (let key of keys)
9
13
  if (!__hasOwnProp.call(target, key) && key !== "default")
10
14
  __defProp(target, key, {
11
- get: () => mod[key],
15
+ get: __accessProp.bind(mod, key),
12
16
  enumerable: true
13
17
  });
14
18
  if (secondTarget) {
15
- for (let key of __getOwnPropNames(mod))
19
+ for (let key of keys)
16
20
  if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
17
21
  __defProp(secondTarget, key, {
18
- get: () => mod[key],
22
+ get: __accessProp.bind(mod, key),
19
23
  enumerable: true
20
24
  });
21
25
  return secondTarget;
22
26
  }
23
27
  };
28
+ var __toESMCache_node;
29
+ var __toESMCache_esm;
24
30
  var __toESM = (mod, isNodeMode, target) => {
31
+ var canCache = mod != null && typeof mod === "object";
32
+ if (canCache) {
33
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
34
+ var cached = cache.get(mod);
35
+ if (cached)
36
+ return cached;
37
+ }
25
38
  target = mod != null ? __create(__getProtoOf(mod)) : {};
26
39
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
27
40
  for (let key of __getOwnPropNames(mod))
28
41
  if (!__hasOwnProp.call(to, key))
29
42
  __defProp(to, key, {
30
- get: () => mod[key],
43
+ get: __accessProp.bind(mod, key),
31
44
  enumerable: true
32
45
  });
46
+ if (canCache)
47
+ cache.set(mod, to);
33
48
  return to;
34
49
  };
35
50
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
+ var __returnValue = (v) => v;
52
+ function __exportSetter(name, newValue) {
53
+ this[name] = __returnValue.bind(null, newValue);
54
+ }
36
55
  var __export = (target, all) => {
37
56
  for (var name in all)
38
57
  __defProp(target, name, {
39
58
  get: all[name],
40
59
  enumerable: true,
41
60
  configurable: true,
42
- set: (newValue) => all[name] = () => newValue
61
+ set: __exportSetter.bind(all, name)
43
62
  });
44
63
  };
45
64
  var __require = import.meta.require;
@@ -5560,7 +5579,7 @@ var require_bcrypt_pbkdf = __commonJS((exports, module) => {
5560
5579
 
5561
5580
  // ../../node_modules/.bun/cpu-features@0.0.10/node_modules/cpu-features/build/Release/cpufeatures.node
5562
5581
  var require_cpufeatures = __commonJS((exports, module) => {
5563
- module.exports = __require("./cpufeatures-6knf6x1a.node");
5582
+ module.exports = __require("./cpufeatures-jxwx4v5j.node");
5564
5583
  });
5565
5584
 
5566
5585
  // ../../node_modules/.bun/cpu-features@0.0.10/node_modules/cpu-features/lib/index.js
@@ -6173,12 +6192,12 @@ var require_utils = __commonJS((exports, module) => {
6173
6192
 
6174
6193
  // ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node
6175
6194
  var require_sshcrypto = __commonJS((exports, module) => {
6176
- module.exports = __require("./sshcrypto-6px2c22x.node");
6195
+ module.exports = __require("./sshcrypto-sx6755rw.node");
6177
6196
  });
6178
6197
 
6179
6198
  // ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js
6180
6199
  var require_poly1305 = __commonJS((exports, module) => {
6181
- var __dirname = "/home/krhougs/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto", __filename = "/home/krhougs/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js";
6200
+ var __dirname = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto", __filename = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/protocol/crypto/poly1305.js";
6182
6201
  var createPoly1305 = function() {
6183
6202
  var _scriptDir = typeof document !== "undefined" && document.currentScript ? document.currentScript.src : undefined;
6184
6203
  if (typeof __filename !== "undefined")
@@ -8951,7 +8970,7 @@ ${formatted}-----END ${type} KEY-----`;
8951
8970
 
8952
8971
  // ../../node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib/agent.js
8953
8972
  var require_agent = __commonJS((exports, module) => {
8954
- var __dirname = "/home/krhougs/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib";
8973
+ var __dirname = "/Users/krhougs/LocalCodes/tmex/node_modules/.bun/ssh2@1.17.0/node_modules/ssh2/lib";
8955
8974
  var { Socket } = __require("net");
8956
8975
  var { Duplex } = __require("stream");
8957
8976
  var { resolve } = __require("path");
@@ -20262,7 +20281,7 @@ var require_lib3 = __commonJS((exports, module) => {
20262
20281
  });
20263
20282
 
20264
20283
  // src/runtime/server.ts
20265
- import { existsSync as existsSync2 } from "fs";
20284
+ import { existsSync as existsSync3 } from "fs";
20266
20285
  import { extname, join as join2, normalize, resolve as resolve2, sep } from "path";
20267
20286
 
20268
20287
  // ../../apps/gateway/src/crypto/errors.ts
@@ -22210,14 +22229,9 @@ function decodePaneWire(wire) {
22210
22229
  height: wire.height
22211
22230
  };
22212
22231
  }
22213
- // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
22214
- var byteToHex = [];
22215
- for (let i = 0;i < 256; ++i) {
22216
- byteToHex.push((i + 256).toString(16).slice(1));
22217
- }
22218
- function unsafeStringify(arr, offset = 0) {
22219
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
22220
- }
22232
+ // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
22233
+ import { randomUUID } from "crypto";
22234
+ var native_default = { randomUUID };
22221
22235
 
22222
22236
  // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/rng.js
22223
22237
  import { randomFillSync } from "crypto";
@@ -22231,9 +22245,14 @@ function rng() {
22231
22245
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
22232
22246
  }
22233
22247
 
22234
- // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/native.js
22235
- import { randomUUID } from "crypto";
22236
- var native_default = { randomUUID };
22248
+ // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/stringify.js
22249
+ var byteToHex = [];
22250
+ for (let i = 0;i < 256; ++i) {
22251
+ byteToHex.push((i + 256).toString(16).slice(1));
22252
+ }
22253
+ function unsafeStringify(arr, offset = 0) {
22254
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
22255
+ }
22237
22256
 
22238
22257
  // ../../node_modules/.bun/uuid@11.1.0/node_modules/uuid/dist/esm/v4.js
22239
22258
  function v4(options, buf, offset) {
@@ -51846,6 +51865,140 @@ var eventNotifier = new EventNotifier;
51846
51865
 
51847
51866
  // ../../apps/gateway/src/tmux/connection.ts
51848
51867
  var import_ssh2 = __toESM(require_lib3(), 1);
51868
+ import { homedir } from "os";
51869
+
51870
+ // ../../apps/gateway/src/tmux/local-shell-path.ts
51871
+ import { existsSync } from "fs";
51872
+ var SHELL_ENV_BEGIN_MARKER = "__TMEX_SHELL_ENV_BEGIN__";
51873
+ var SHELL_ENV_END_MARKER = "__TMEX_SHELL_ENV_END__";
51874
+ var SHELL_ENV_PROBE_COMMAND = `printf '${SHELL_ENV_BEGIN_MARKER}\\n'; /usr/bin/env; printf '${SHELL_ENV_END_MARKER}\\n'`;
51875
+ function defaultRunSync(cmd) {
51876
+ const result = Bun.spawnSync(cmd, {
51877
+ env: process.env,
51878
+ stdout: "pipe",
51879
+ stderr: "pipe"
51880
+ });
51881
+ return {
51882
+ exitCode: result.exitCode,
51883
+ stdout: Buffer.from(result.stdout).toString("utf8"),
51884
+ stderr: Buffer.from(result.stderr).toString("utf8")
51885
+ };
51886
+ }
51887
+ function resolveShellFromDscl(deps) {
51888
+ if (deps.platform !== "darwin") {
51889
+ return null;
51890
+ }
51891
+ const username = deps.env.USER?.trim() || deps.env.LOGNAME?.trim();
51892
+ if (!username) {
51893
+ return null;
51894
+ }
51895
+ const result = deps.runSync(["/usr/bin/dscl", ".", "-read", `/Users/${username}`, "UserShell"]);
51896
+ if (result.exitCode !== 0) {
51897
+ return null;
51898
+ }
51899
+ const matched = result.stdout.match(/UserShell:\s*(\S+)/);
51900
+ const shellPath = matched?.[1]?.trim();
51901
+ if (!shellPath || !deps.fileExists(shellPath)) {
51902
+ return null;
51903
+ }
51904
+ return shellPath;
51905
+ }
51906
+ function resolveDefaultShell(deps) {
51907
+ const envShell = deps.env.SHELL?.trim();
51908
+ if (envShell && deps.fileExists(envShell)) {
51909
+ return envShell;
51910
+ }
51911
+ const dsclShell = resolveShellFromDscl(deps);
51912
+ if (dsclShell) {
51913
+ return dsclShell;
51914
+ }
51915
+ const fallbackShell = deps.platform === "darwin" ? "/bin/zsh" : "/bin/bash";
51916
+ if (deps.fileExists(fallbackShell)) {
51917
+ return fallbackShell;
51918
+ }
51919
+ return null;
51920
+ }
51921
+ function extractPathFromShellEnv(stdout) {
51922
+ const beginIndex = stdout.lastIndexOf(SHELL_ENV_BEGIN_MARKER);
51923
+ if (beginIndex < 0) {
51924
+ return null;
51925
+ }
51926
+ const endIndex = stdout.indexOf(SHELL_ENV_END_MARKER, beginIndex + SHELL_ENV_BEGIN_MARKER.length);
51927
+ if (endIndex < 0) {
51928
+ return null;
51929
+ }
51930
+ const body = stdout.slice(beginIndex + SHELL_ENV_BEGIN_MARKER.length, endIndex);
51931
+ for (const rawLine of body.split(/\r?\n/)) {
51932
+ const line = rawLine.trim();
51933
+ if (!line.startsWith("PATH=")) {
51934
+ continue;
51935
+ }
51936
+ const value = line.slice("PATH=".length).trim();
51937
+ return value.length > 0 ? value : null;
51938
+ }
51939
+ return null;
51940
+ }
51941
+ function probeShellPath(shellPath, deps) {
51942
+ const attempts = [
51943
+ [shellPath, "-l", "-c", SHELL_ENV_PROBE_COMMAND],
51944
+ [shellPath, "-l", "-i", "-c", SHELL_ENV_PROBE_COMMAND],
51945
+ [shellPath, "-c", SHELL_ENV_PROBE_COMMAND]
51946
+ ];
51947
+ for (const cmd of attempts) {
51948
+ const result = deps.runSync(cmd);
51949
+ if (result.exitCode !== 0) {
51950
+ continue;
51951
+ }
51952
+ const resolvedPath = extractPathFromShellEnv(result.stdout);
51953
+ if (resolvedPath) {
51954
+ return resolvedPath;
51955
+ }
51956
+ }
51957
+ return null;
51958
+ }
51959
+ function createLocalShellPathCache(input = {}) {
51960
+ const deps = {
51961
+ env: input.env ?? process.env,
51962
+ fileExists: input.fileExists ?? existsSync,
51963
+ platform: input.platform ?? process.platform,
51964
+ runSync: input.runSync ?? defaultRunSync
51965
+ };
51966
+ let initialized = false;
51967
+ let cachedPath = null;
51968
+ return {
51969
+ get() {
51970
+ return initialized ? cachedPath : null;
51971
+ },
51972
+ prime() {
51973
+ if (initialized) {
51974
+ return cachedPath;
51975
+ }
51976
+ initialized = true;
51977
+ const shellPath = resolveDefaultShell(deps);
51978
+ if (!shellPath) {
51979
+ return null;
51980
+ }
51981
+ cachedPath = probeShellPath(shellPath, deps);
51982
+ return cachedPath;
51983
+ }
51984
+ };
51985
+ }
51986
+ var defaultLocalShellPathCache = createLocalShellPathCache();
51987
+ function primeLocalShellPath() {
51988
+ return defaultLocalShellPathCache.prime();
51989
+ }
51990
+ function getLocalShellPath() {
51991
+ return defaultLocalShellPathCache.get();
51992
+ }
51993
+ function buildLocalTmuxEnv(resolvedPath, baseEnv = process.env) {
51994
+ if (!resolvedPath) {
51995
+ return { ...baseEnv };
51996
+ }
51997
+ return {
51998
+ ...baseEnv,
51999
+ PATH: resolvedPath
52000
+ };
52001
+ }
51849
52002
 
51850
52003
  // ../../apps/gateway/src/tmux/ssh-auth.ts
51851
52004
  function normalizeEnvValue(value) {
@@ -52321,6 +52474,9 @@ class TmuxControlParser {
52321
52474
 
52322
52475
  // ../../apps/gateway/src/tmux/connection.ts
52323
52476
  var BELL_DEDUP_WINDOW_MS = 200;
52477
+ function buildLocalTmuxCommand(sessionName, startDirectory) {
52478
+ return ["tmux", "-CC", "new-session", "-A", "-c", startDirectory, "-s", sessionName];
52479
+ }
52324
52480
 
52325
52481
  class TmuxConnection {
52326
52482
  deviceId;
@@ -52441,7 +52597,10 @@ ${detail}`) : error;
52441
52597
  }
52442
52598
  async connectLocal() {
52443
52599
  const sessionName = this.device?.session ?? "tmex";
52444
- this.subprocess = Bun.spawn(["tmux", "-CC", "new-session", "-A", "-s", sessionName], {
52600
+ const env = buildLocalTmuxEnv(getLocalShellPath());
52601
+ const startDirectory = homedir();
52602
+ this.subprocess = Bun.spawn(buildLocalTmuxCommand(sessionName, startDirectory), {
52603
+ env,
52445
52604
  terminal: {
52446
52605
  name: "xterm-256color",
52447
52606
  cols: 80,
@@ -53951,7 +54110,7 @@ function json(data, status = 200, headers = {}) {
53951
54110
  }
53952
54111
 
53953
54112
  // ../../apps/gateway/src/db/migrate.ts
53954
- import { existsSync } from "fs";
54113
+ import { existsSync as existsSync2 } from "fs";
53955
54114
  import { resolve } from "path";
53956
54115
 
53957
54116
  // ../../node_modules/.bun/drizzle-orm@0.45.1+3f568c6259dbead9/node_modules/drizzle-orm/migrator.js
@@ -53998,7 +54157,7 @@ function resolveMigrationsFolder() {
53998
54157
  if (fromEnv)
53999
54158
  return fromEnv;
54000
54159
  const byCwd = resolve(process.cwd(), "drizzle");
54001
- if (existsSync(byCwd))
54160
+ if (existsSync2(byCwd))
54002
54161
  return byCwd;
54003
54162
  return resolve(import.meta.dir, "../../drizzle");
54004
54163
  }
@@ -55287,6 +55446,7 @@ async function createGatewayRuntime(options = {}) {
55287
55446
  ensureSiteSettingsInitialized();
55288
55447
  }
55289
55448
  runtimeController.reset();
55449
+ primeLocalShellPath();
55290
55450
  const wsServer = new WebSocketServer;
55291
55451
  await telegramService.refresh();
55292
55452
  await pushSupervisor.start();
@@ -55599,8 +55759,8 @@ async function serveFrontend(req, staticRoot) {
55599
55759
  return new Response(t3("runtime.forbidden"), { status: 403 });
55600
55760
  }
55601
55761
  const indexPath = join2(staticRoot, "index.html");
55602
- const targetPath = existsSync2(requestedPath) ? requestedPath : indexPath;
55603
- if (!existsSync2(targetPath)) {
55762
+ const targetPath = existsSync3(requestedPath) ? requestedPath : indexPath;
55763
+ if (!existsSync3(targetPath)) {
55604
55764
  return new Response(t3("runtime.frontendMissing"), { status: 500 });
55605
55765
  }
55606
55766
  const headers = new Headers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmex-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "tmex": "./bin/tmex.js",