tmex-cli 0.2.3 → 0.2.5
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.
|
Binary file
|
package/dist/runtime/server.js
CHANGED
|
@@ -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
|
-
|
|
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: (
|
|
15
|
+
get: __accessProp.bind(mod, key),
|
|
12
16
|
enumerable: true
|
|
13
17
|
});
|
|
14
18
|
if (secondTarget) {
|
|
15
|
-
for (let key of
|
|
19
|
+
for (let key of keys)
|
|
16
20
|
if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
|
|
17
21
|
__defProp(secondTarget, key, {
|
|
18
|
-
get: (
|
|
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: (
|
|
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: (
|
|
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-
|
|
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-
|
|
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 = "/
|
|
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 = "/
|
|
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,8 +20281,8 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
20262
20281
|
});
|
|
20263
20282
|
|
|
20264
20283
|
// src/runtime/server.ts
|
|
20265
|
-
import { existsSync as
|
|
20266
|
-
import { extname, join as
|
|
20284
|
+
import { existsSync as existsSync3 } from "fs";
|
|
20285
|
+
import { extname, join as join3, normalize, resolve as resolve2, sep } from "path";
|
|
20267
20286
|
|
|
20268
20287
|
// ../../apps/gateway/src/crypto/errors.ts
|
|
20269
20288
|
function contextLabel(context) {
|
|
@@ -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/
|
|
22214
|
-
|
|
22215
|
-
|
|
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/
|
|
22235
|
-
|
|
22236
|
-
|
|
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,158 @@ 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
|
+
import { delimiter, join as join2 } from "path";
|
|
51873
|
+
var SHELL_ENV_BEGIN_MARKER = "__TMEX_SHELL_ENV_BEGIN__";
|
|
51874
|
+
var SHELL_ENV_END_MARKER = "__TMEX_SHELL_ENV_END__";
|
|
51875
|
+
var SHELL_ENV_PROBE_COMMAND = `printf '${SHELL_ENV_BEGIN_MARKER}\\n'; /usr/bin/env; printf '${SHELL_ENV_END_MARKER}\\n'`;
|
|
51876
|
+
function defaultRunSync(cmd) {
|
|
51877
|
+
const result = Bun.spawnSync(cmd, {
|
|
51878
|
+
env: process.env,
|
|
51879
|
+
stdout: "pipe",
|
|
51880
|
+
stderr: "pipe"
|
|
51881
|
+
});
|
|
51882
|
+
return {
|
|
51883
|
+
exitCode: result.exitCode,
|
|
51884
|
+
stdout: Buffer.from(result.stdout).toString("utf8"),
|
|
51885
|
+
stderr: Buffer.from(result.stderr).toString("utf8")
|
|
51886
|
+
};
|
|
51887
|
+
}
|
|
51888
|
+
function resolveShellFromDscl(deps) {
|
|
51889
|
+
if (deps.platform !== "darwin") {
|
|
51890
|
+
return null;
|
|
51891
|
+
}
|
|
51892
|
+
const username = deps.env.USER?.trim() || deps.env.LOGNAME?.trim();
|
|
51893
|
+
if (!username) {
|
|
51894
|
+
return null;
|
|
51895
|
+
}
|
|
51896
|
+
const result = deps.runSync(["/usr/bin/dscl", ".", "-read", `/Users/${username}`, "UserShell"]);
|
|
51897
|
+
if (result.exitCode !== 0) {
|
|
51898
|
+
return null;
|
|
51899
|
+
}
|
|
51900
|
+
const matched = result.stdout.match(/UserShell:\s*(\S+)/);
|
|
51901
|
+
const shellPath = matched?.[1]?.trim();
|
|
51902
|
+
if (!shellPath || !deps.fileExists(shellPath)) {
|
|
51903
|
+
return null;
|
|
51904
|
+
}
|
|
51905
|
+
return shellPath;
|
|
51906
|
+
}
|
|
51907
|
+
function resolveDefaultShell(deps) {
|
|
51908
|
+
const envShell = deps.env.SHELL?.trim();
|
|
51909
|
+
if (envShell && deps.fileExists(envShell)) {
|
|
51910
|
+
return envShell;
|
|
51911
|
+
}
|
|
51912
|
+
const dsclShell = resolveShellFromDscl(deps);
|
|
51913
|
+
if (dsclShell) {
|
|
51914
|
+
return dsclShell;
|
|
51915
|
+
}
|
|
51916
|
+
const fallbackShell = deps.platform === "darwin" ? "/bin/zsh" : "/bin/bash";
|
|
51917
|
+
if (deps.fileExists(fallbackShell)) {
|
|
51918
|
+
return fallbackShell;
|
|
51919
|
+
}
|
|
51920
|
+
return null;
|
|
51921
|
+
}
|
|
51922
|
+
function extractPathFromShellEnv(stdout) {
|
|
51923
|
+
const beginIndex = stdout.lastIndexOf(SHELL_ENV_BEGIN_MARKER);
|
|
51924
|
+
if (beginIndex < 0) {
|
|
51925
|
+
return null;
|
|
51926
|
+
}
|
|
51927
|
+
const endIndex = stdout.indexOf(SHELL_ENV_END_MARKER, beginIndex + SHELL_ENV_BEGIN_MARKER.length);
|
|
51928
|
+
if (endIndex < 0) {
|
|
51929
|
+
return null;
|
|
51930
|
+
}
|
|
51931
|
+
const body = stdout.slice(beginIndex + SHELL_ENV_BEGIN_MARKER.length, endIndex);
|
|
51932
|
+
for (const rawLine of body.split(/\r?\n/)) {
|
|
51933
|
+
const line = rawLine.trim();
|
|
51934
|
+
if (!line.startsWith("PATH=")) {
|
|
51935
|
+
continue;
|
|
51936
|
+
}
|
|
51937
|
+
const value = line.slice("PATH=".length).trim();
|
|
51938
|
+
return value.length > 0 ? value : null;
|
|
51939
|
+
}
|
|
51940
|
+
return null;
|
|
51941
|
+
}
|
|
51942
|
+
function canResolveExecutableFromPath(resolvedPath, executableName, deps) {
|
|
51943
|
+
for (const rawDir of resolvedPath.split(delimiter)) {
|
|
51944
|
+
const dir2 = rawDir.trim();
|
|
51945
|
+
if (!dir2) {
|
|
51946
|
+
continue;
|
|
51947
|
+
}
|
|
51948
|
+
if (deps.fileExists(join2(dir2, executableName))) {
|
|
51949
|
+
return true;
|
|
51950
|
+
}
|
|
51951
|
+
}
|
|
51952
|
+
return false;
|
|
51953
|
+
}
|
|
51954
|
+
function probeShellPath(shellPath, deps) {
|
|
51955
|
+
const attempts = [
|
|
51956
|
+
[shellPath, "-l", "-c", SHELL_ENV_PROBE_COMMAND],
|
|
51957
|
+
[shellPath, "-l", "-i", "-c", SHELL_ENV_PROBE_COMMAND],
|
|
51958
|
+
[shellPath, "-c", SHELL_ENV_PROBE_COMMAND]
|
|
51959
|
+
];
|
|
51960
|
+
let fallbackPath = null;
|
|
51961
|
+
for (const cmd of attempts) {
|
|
51962
|
+
const result = deps.runSync(cmd);
|
|
51963
|
+
if (result.exitCode !== 0) {
|
|
51964
|
+
continue;
|
|
51965
|
+
}
|
|
51966
|
+
const resolvedPath = extractPathFromShellEnv(result.stdout);
|
|
51967
|
+
if (!resolvedPath) {
|
|
51968
|
+
continue;
|
|
51969
|
+
}
|
|
51970
|
+
fallbackPath ??= resolvedPath;
|
|
51971
|
+
if (canResolveExecutableFromPath(resolvedPath, "tmux", deps)) {
|
|
51972
|
+
return resolvedPath;
|
|
51973
|
+
}
|
|
51974
|
+
}
|
|
51975
|
+
return fallbackPath;
|
|
51976
|
+
}
|
|
51977
|
+
function createLocalShellPathCache(input = {}) {
|
|
51978
|
+
const deps = {
|
|
51979
|
+
env: input.env ?? process.env,
|
|
51980
|
+
fileExists: input.fileExists ?? existsSync,
|
|
51981
|
+
platform: input.platform ?? process.platform,
|
|
51982
|
+
runSync: input.runSync ?? defaultRunSync
|
|
51983
|
+
};
|
|
51984
|
+
let initialized = false;
|
|
51985
|
+
let cachedPath = null;
|
|
51986
|
+
return {
|
|
51987
|
+
get() {
|
|
51988
|
+
return initialized ? cachedPath : null;
|
|
51989
|
+
},
|
|
51990
|
+
prime() {
|
|
51991
|
+
if (initialized) {
|
|
51992
|
+
return cachedPath;
|
|
51993
|
+
}
|
|
51994
|
+
initialized = true;
|
|
51995
|
+
const shellPath = resolveDefaultShell(deps);
|
|
51996
|
+
if (!shellPath) {
|
|
51997
|
+
return null;
|
|
51998
|
+
}
|
|
51999
|
+
cachedPath = probeShellPath(shellPath, deps);
|
|
52000
|
+
return cachedPath;
|
|
52001
|
+
}
|
|
52002
|
+
};
|
|
52003
|
+
}
|
|
52004
|
+
var defaultLocalShellPathCache = createLocalShellPathCache();
|
|
52005
|
+
function primeLocalShellPath() {
|
|
52006
|
+
return defaultLocalShellPathCache.prime();
|
|
52007
|
+
}
|
|
52008
|
+
function getLocalShellPath() {
|
|
52009
|
+
return defaultLocalShellPathCache.get();
|
|
52010
|
+
}
|
|
52011
|
+
function buildLocalTmuxEnv(resolvedPath, baseEnv = process.env) {
|
|
52012
|
+
if (!resolvedPath) {
|
|
52013
|
+
return { ...baseEnv };
|
|
52014
|
+
}
|
|
52015
|
+
return {
|
|
52016
|
+
...baseEnv,
|
|
52017
|
+
PATH: resolvedPath
|
|
52018
|
+
};
|
|
52019
|
+
}
|
|
51849
52020
|
|
|
51850
52021
|
// ../../apps/gateway/src/tmux/ssh-auth.ts
|
|
51851
52022
|
function normalizeEnvValue(value) {
|
|
@@ -52321,6 +52492,9 @@ class TmuxControlParser {
|
|
|
52321
52492
|
|
|
52322
52493
|
// ../../apps/gateway/src/tmux/connection.ts
|
|
52323
52494
|
var BELL_DEDUP_WINDOW_MS = 200;
|
|
52495
|
+
function buildLocalTmuxCommand(sessionName, startDirectory) {
|
|
52496
|
+
return ["tmux", "-CC", "new-session", "-A", "-c", startDirectory, "-s", sessionName];
|
|
52497
|
+
}
|
|
52324
52498
|
|
|
52325
52499
|
class TmuxConnection {
|
|
52326
52500
|
deviceId;
|
|
@@ -52441,7 +52615,10 @@ ${detail}`) : error;
|
|
|
52441
52615
|
}
|
|
52442
52616
|
async connectLocal() {
|
|
52443
52617
|
const sessionName = this.device?.session ?? "tmex";
|
|
52444
|
-
|
|
52618
|
+
const env = buildLocalTmuxEnv(getLocalShellPath());
|
|
52619
|
+
const startDirectory = homedir();
|
|
52620
|
+
this.subprocess = Bun.spawn(buildLocalTmuxCommand(sessionName, startDirectory), {
|
|
52621
|
+
env,
|
|
52445
52622
|
terminal: {
|
|
52446
52623
|
name: "xterm-256color",
|
|
52447
52624
|
cols: 80,
|
|
@@ -53951,7 +54128,7 @@ function json(data, status = 200, headers = {}) {
|
|
|
53951
54128
|
}
|
|
53952
54129
|
|
|
53953
54130
|
// ../../apps/gateway/src/db/migrate.ts
|
|
53954
|
-
import { existsSync } from "fs";
|
|
54131
|
+
import { existsSync as existsSync2 } from "fs";
|
|
53955
54132
|
import { resolve } from "path";
|
|
53956
54133
|
|
|
53957
54134
|
// ../../node_modules/.bun/drizzle-orm@0.45.1+3f568c6259dbead9/node_modules/drizzle-orm/migrator.js
|
|
@@ -53998,7 +54175,7 @@ function resolveMigrationsFolder() {
|
|
|
53998
54175
|
if (fromEnv)
|
|
53999
54176
|
return fromEnv;
|
|
54000
54177
|
const byCwd = resolve(process.cwd(), "drizzle");
|
|
54001
|
-
if (
|
|
54178
|
+
if (existsSync2(byCwd))
|
|
54002
54179
|
return byCwd;
|
|
54003
54180
|
return resolve(import.meta.dir, "../../drizzle");
|
|
54004
54181
|
}
|
|
@@ -55287,6 +55464,7 @@ async function createGatewayRuntime(options = {}) {
|
|
|
55287
55464
|
ensureSiteSettingsInitialized();
|
|
55288
55465
|
}
|
|
55289
55466
|
runtimeController.reset();
|
|
55467
|
+
primeLocalShellPath();
|
|
55290
55468
|
const wsServer = new WebSocketServer;
|
|
55291
55469
|
await telegramService.refresh();
|
|
55292
55470
|
await pushSupervisor.start();
|
|
@@ -55598,9 +55776,9 @@ async function serveFrontend(req, staticRoot) {
|
|
|
55598
55776
|
if (!requestedPath) {
|
|
55599
55777
|
return new Response(t3("runtime.forbidden"), { status: 403 });
|
|
55600
55778
|
}
|
|
55601
|
-
const indexPath =
|
|
55602
|
-
const targetPath =
|
|
55603
|
-
if (!
|
|
55779
|
+
const indexPath = join3(staticRoot, "index.html");
|
|
55780
|
+
const targetPath = existsSync3(requestedPath) ? requestedPath : indexPath;
|
|
55781
|
+
if (!existsSync3(targetPath)) {
|
|
55604
55782
|
return new Response(t3("runtime.frontendMissing"), { status: 500 });
|
|
55605
55783
|
}
|
|
55606
55784
|
const headers = new Headers;
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|