@askexenow/exe-os 0.8.1 → 0.8.2

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 (106) hide show
  1. package/package.json +1 -1
  2. package/dist/bin/backfill-responses.js +0 -2064
  3. package/dist/bin/backfill-vectors.js +0 -1771
  4. package/dist/bin/cleanup-stale-review-tasks.js +0 -1468
  5. package/dist/bin/cli.js +0 -21371
  6. package/dist/bin/exe-agent.js +0 -2016
  7. package/dist/bin/exe-assign.js +0 -2176
  8. package/dist/bin/exe-boot.js +0 -6332
  9. package/dist/bin/exe-call.js +0 -341
  10. package/dist/bin/exe-cloud.js +0 -861
  11. package/dist/bin/exe-dispatch.js +0 -1159
  12. package/dist/bin/exe-doctor.js +0 -1786
  13. package/dist/bin/exe-export-behaviors.js +0 -1637
  14. package/dist/bin/exe-forget.js +0 -1784
  15. package/dist/bin/exe-gateway.js +0 -8140
  16. package/dist/bin/exe-healthcheck.js +0 -207
  17. package/dist/bin/exe-heartbeat.js +0 -1778
  18. package/dist/bin/exe-kill.js +0 -1622
  19. package/dist/bin/exe-launch-agent.js +0 -1847
  20. package/dist/bin/exe-link.js +0 -192
  21. package/dist/bin/exe-new-employee.js +0 -1384
  22. package/dist/bin/exe-pending-messages.js +0 -1576
  23. package/dist/bin/exe-pending-notifications.js +0 -1450
  24. package/dist/bin/exe-pending-reviews.js +0 -1598
  25. package/dist/bin/exe-repo-drift.js +0 -95
  26. package/dist/bin/exe-review.js +0 -1742
  27. package/dist/bin/exe-search.js +0 -3116
  28. package/dist/bin/exe-session-cleanup.js +0 -3360
  29. package/dist/bin/exe-settings.js +0 -365
  30. package/dist/bin/exe-status.js +0 -1661
  31. package/dist/bin/exe-team.js +0 -1453
  32. package/dist/bin/git-sweep.js +0 -2441
  33. package/dist/bin/graph-backfill.js +0 -2111
  34. package/dist/bin/graph-export.js +0 -1747
  35. package/dist/bin/install.js +0 -661
  36. package/dist/bin/list-providers.js +0 -140
  37. package/dist/bin/scan-tasks.js +0 -2039
  38. package/dist/bin/setup.js +0 -2717
  39. package/dist/bin/shard-migrate.js +0 -1637
  40. package/dist/bin/update.js +0 -98
  41. package/dist/bin/wiki-sync.js +0 -1657
  42. package/dist/gateway/index.js +0 -9256
  43. package/dist/hooks/bug-report-worker.js +0 -2903
  44. package/dist/hooks/commit-complete.js +0 -2364
  45. package/dist/hooks/error-recall.js +0 -3327
  46. package/dist/hooks/exe-heartbeat-hook.js +0 -237
  47. package/dist/hooks/ingest-worker.js +0 -5065
  48. package/dist/hooks/ingest.js +0 -695
  49. package/dist/hooks/instructions-loaded.js +0 -2069
  50. package/dist/hooks/notification.js +0 -1915
  51. package/dist/hooks/post-compact.js +0 -1940
  52. package/dist/hooks/pre-compact.js +0 -1935
  53. package/dist/hooks/pre-tool-use.js +0 -2380
  54. package/dist/hooks/prompt-ingest-worker.js +0 -2291
  55. package/dist/hooks/prompt-submit.js +0 -5189
  56. package/dist/hooks/response-ingest-worker.js +0 -2431
  57. package/dist/hooks/session-end.js +0 -2196
  58. package/dist/hooks/session-start.js +0 -3259
  59. package/dist/hooks/stop.js +0 -2025
  60. package/dist/hooks/subagent-stop.js +0 -1915
  61. package/dist/hooks/summary-worker.js +0 -2931
  62. package/dist/index.js +0 -12327
  63. package/dist/lib/cloud-sync.js +0 -500
  64. package/dist/lib/config.js +0 -235
  65. package/dist/lib/consolidation.js +0 -481
  66. package/dist/lib/crypto.js +0 -51
  67. package/dist/lib/database.js +0 -834
  68. package/dist/lib/device-registry.js +0 -1009
  69. package/dist/lib/embedder.js +0 -645
  70. package/dist/lib/employee-templates.js +0 -570
  71. package/dist/lib/employees.js +0 -182
  72. package/dist/lib/error-detector.js +0 -156
  73. package/dist/lib/exe-daemon-client.js +0 -456
  74. package/dist/lib/exe-daemon.js +0 -8699
  75. package/dist/lib/file-grep.js +0 -215
  76. package/dist/lib/hybrid-search.js +0 -3064
  77. package/dist/lib/identity-templates.js +0 -441
  78. package/dist/lib/identity.js +0 -228
  79. package/dist/lib/keychain.js +0 -145
  80. package/dist/lib/license.js +0 -382
  81. package/dist/lib/messaging.js +0 -1389
  82. package/dist/lib/reminders.js +0 -63
  83. package/dist/lib/schedules.js +0 -1525
  84. package/dist/lib/session-registry.js +0 -52
  85. package/dist/lib/skill-learning.js +0 -488
  86. package/dist/lib/status-brief.js +0 -240
  87. package/dist/lib/store.js +0 -1740
  88. package/dist/lib/task-router.js +0 -128
  89. package/dist/lib/tasks.js +0 -2585
  90. package/dist/lib/tmux-routing.js +0 -2969
  91. package/dist/lib/tmux-status.js +0 -261
  92. package/dist/lib/tmux-transport.js +0 -83
  93. package/dist/lib/transport.js +0 -128
  94. package/dist/lib/ws-auth.js +0 -19
  95. package/dist/lib/ws-client.js +0 -160
  96. package/dist/mcp/server.js +0 -10812
  97. package/dist/mcp/tools/complete-reminder.js +0 -67
  98. package/dist/mcp/tools/create-reminder.js +0 -52
  99. package/dist/mcp/tools/create-task.js +0 -1903
  100. package/dist/mcp/tools/deactivate-behavior.js +0 -268
  101. package/dist/mcp/tools/list-reminders.js +0 -62
  102. package/dist/mcp/tools/list-tasks.js +0 -491
  103. package/dist/mcp/tools/send-message.js +0 -1395
  104. package/dist/mcp/tools/update-task.js +0 -1807
  105. package/dist/runtime/index.js +0 -7201
  106. package/dist/tui/App.js +0 -17874
@@ -1,261 +0,0 @@
1
- // src/lib/tmux-status.ts
2
- import { execSync } from "child_process";
3
- function inTmux() {
4
- if (process.env.TMUX || process.env.TMUX_PANE) return true;
5
- const term = process.env.TERM ?? "";
6
- if (term.startsWith("tmux") || term.startsWith("screen")) return true;
7
- try {
8
- execSync("tmux display-message -p '#{session_name}' 2>/dev/null", {
9
- encoding: "utf8",
10
- timeout: 2e3
11
- });
12
- return true;
13
- } catch {
14
- }
15
- try {
16
- let pid = process.ppid;
17
- for (let depth = 0; depth < 8 && pid > 1; depth++) {
18
- const comm = execSync(`ps -p ${pid} -o comm= 2>/dev/null`, {
19
- encoding: "utf8",
20
- timeout: 1e3
21
- }).trim();
22
- if (/tmux/.test(comm)) return true;
23
- const ppid = execSync(`ps -p ${pid} -o ppid= 2>/dev/null`, {
24
- encoding: "utf8",
25
- timeout: 1e3
26
- }).trim();
27
- pid = parseInt(ppid, 10);
28
- if (isNaN(pid)) break;
29
- }
30
- } catch {
31
- }
32
- return false;
33
- }
34
- function listTmuxSessions() {
35
- try {
36
- const out = execSync("tmux list-sessions -F '#{session_name}' 2>/dev/null", {
37
- encoding: "utf8",
38
- timeout: 3e3
39
- });
40
- return out.trim().split("\n").filter(Boolean);
41
- } catch {
42
- return [];
43
- }
44
- }
45
- var listTmuxWindows = listTmuxSessions;
46
- function capturePaneLines(windowName, lines = 10) {
47
- try {
48
- const out = execSync(
49
- `tmux capture-pane -t ${JSON.stringify(windowName)} -p 2>/dev/null | tail -${lines}`,
50
- { encoding: "utf8", timeout: 3e3 }
51
- );
52
- return out.split("\n").filter((l) => l.trim());
53
- } catch {
54
- return [];
55
- }
56
- }
57
- function getPaneCwd(windowName) {
58
- try {
59
- const out = execSync(
60
- `tmux display-message -t ${JSON.stringify(windowName)} -p '#{pane_current_path}' 2>/dev/null`,
61
- { encoding: "utf8", timeout: 3e3 }
62
- );
63
- return out.trim() || void 0;
64
- } catch {
65
- return void 0;
66
- }
67
- }
68
- function projectFromPath(dir) {
69
- try {
70
- const root = execSync("git -C " + JSON.stringify(dir) + " rev-parse --show-toplevel 2>/dev/null", {
71
- encoding: "utf8",
72
- timeout: 3e3
73
- }).trim();
74
- return root.split("/").pop() ?? dir.split("/").pop() ?? "unknown";
75
- } catch {
76
- return dir.split("/").pop() ?? "unknown";
77
- }
78
- }
79
- function parseActivity(lines) {
80
- const joined = lines.join("\n");
81
- if (/npm\s+test|vitest|jest|pytest|cargo\s+test/i.test(joined)) {
82
- const passMatch = joined.match(/(\d+)\s*passed/i);
83
- if (passMatch) return `Running tests \u2014 ${passMatch[1]} passed`;
84
- return "Running tests...";
85
- }
86
- if (/Edit\(|Edit\s*\{/.test(joined)) {
87
- const fileMatch = joined.match(/file_path['":\s]+([^\s'"}\]]+)/);
88
- if (fileMatch) return `Editing ${fileMatch[1].split("/").slice(-2).join("/")}`;
89
- return "Editing code...";
90
- }
91
- if (/Write\(|Write\s*\{/.test(joined)) {
92
- const fileMatch = joined.match(/file_path['":\s]+([^\s'"}\]]+)/);
93
- if (fileMatch) return `Writing ${fileMatch[1].split("/").slice(-2).join("/")}`;
94
- return "Writing file...";
95
- }
96
- if (/Bash\(|Bash\s*\{/.test(joined)) {
97
- const cmdMatch = joined.match(/command['":\s]+([^\n'"}{]{1,60})/);
98
- if (cmdMatch) return `Running: ${cmdMatch[1].trim().slice(0, 50)}`;
99
- return "Running command...";
100
- }
101
- if (/git\s+commit/.test(joined)) return "Committing...";
102
- if (/MANDATORY|START WORKING NOW/.test(joined)) return "Starting new task...";
103
- if (/All tasks complete|No open tasks/.test(joined)) return "Idle \u2014 queue empty";
104
- if (/store_memory|recall_my_memory/.test(joined)) return "Accessing memory...";
105
- if (/Agent\(/.test(joined)) return "Spawning sub-agent...";
106
- if (/Read\(|Read\s*\{/.test(joined)) return "Reading files...";
107
- const lastLine = lines.filter((l) => l.trim()).pop();
108
- if (lastLine && lastLine.trim().length > 5) {
109
- return lastLine.trim().slice(0, 60);
110
- }
111
- return "Working...";
112
- }
113
- function parseContextPercentage(sessionName) {
114
- const lines = capturePaneLines(sessionName, 3);
115
- for (const line of lines) {
116
- const match = line.match(/[█░]+\s*(\d+)%/);
117
- if (match) {
118
- return parseInt(match[1], 10);
119
- }
120
- }
121
- return null;
122
- }
123
- function getEmployeeStatuses(employeeNames) {
124
- if (!inTmux() || process.env.VITEST) {
125
- return employeeNames.map((name) => ({
126
- name,
127
- hasWindow: false,
128
- icon: "\u26AA"
129
- }));
130
- }
131
- const sessions = new Set(listTmuxSessions());
132
- return employeeNames.map((name) => {
133
- const sessionName = [...sessions].find((s) => s.startsWith(`${name}-`));
134
- if (!sessionName) {
135
- return { name, hasWindow: false, icon: "\u26AA" };
136
- }
137
- let paneAlive = true;
138
- try {
139
- const paneStatus = execSync(
140
- `tmux list-panes -t ${JSON.stringify(sessionName)} -F '#{pane_dead}' 2>/dev/null`,
141
- { encoding: "utf8", timeout: 3e3 }
142
- ).trim();
143
- if (paneStatus === "1") paneAlive = false;
144
- } catch {
145
- paneAlive = false;
146
- }
147
- if (!paneAlive) {
148
- return { name, hasWindow: false, icon: "\u26AA" };
149
- }
150
- const rawLines = capturePaneLines(sessionName, 10);
151
- const cwd = getPaneCwd(sessionName);
152
- const project = cwd ? projectFromPath(cwd) : void 0;
153
- const activity = rawLines.length > 0 ? parseActivity(rawLines) : "Session active";
154
- return {
155
- name,
156
- hasWindow: true,
157
- project,
158
- activity,
159
- rawLines,
160
- icon: "\u{1F7E2}"
161
- };
162
- });
163
- }
164
- function formatTeamCondensed(statuses) {
165
- const byProject = /* @__PURE__ */ new Map();
166
- for (const s of statuses) {
167
- const proj = s.project ?? "(no session)";
168
- if (!byProject.has(proj)) byProject.set(proj, []);
169
- byProject.get(proj).push(s);
170
- }
171
- const lines = [];
172
- for (const [proj, emps] of byProject) {
173
- const parts = emps.map((e) => {
174
- if (!e.hasWindow) return `${e.name} offline`;
175
- return `${e.name} ${e.activity?.toLowerCase().slice(0, 40) ?? "active"}`;
176
- });
177
- lines.push(` ${proj}: ${parts.join(", ")}`);
178
- }
179
- return lines;
180
- }
181
- function formatStatusAll(statuses, tasks, roles) {
182
- const byProject = /* @__PURE__ */ new Map();
183
- for (const s of statuses) {
184
- const proj = s.project ?? "(no session)";
185
- if (!byProject.has(proj)) byProject.set(proj, []);
186
- byProject.get(proj).push(s);
187
- }
188
- const lines = [];
189
- lines.push("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
190
- lines.push("\u2502 REAL-TIME STATUS \u2502");
191
- lines.push("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
192
- lines.push("");
193
- for (const [proj, emps] of byProject) {
194
- lines.push(`\u250C\u2500 ${proj} ${"\u2500".repeat(Math.max(0, 66 - proj.length))}\u2510`);
195
- if (emps.every((e) => !e.hasWindow)) {
196
- lines.push("\u2502 No active employees" + " ".repeat(49) + "\u2502");
197
- } else {
198
- for (let i = 0; i < emps.length; i++) {
199
- const e = emps[i];
200
- const role = roles.get(e.name) ?? "";
201
- const roleSuffix = role ? ` (${role})` : "";
202
- const nameCol = `${e.name}${roleSuffix}`.padEnd(14);
203
- const task = tasks.get(e.name);
204
- if (!e.hasWindow) {
205
- const statusLine = `\u2502 ${nameCol} \u2502 \u26AA No tmux session`;
206
- lines.push(statusLine + " ".repeat(Math.max(0, 70 - statusLine.length)) + "\u2502");
207
- } else {
208
- const actLine = `\u2502 ${nameCol} \u2502 ${e.icon} ${(e.activity ?? "Active").slice(0, 45)}`;
209
- lines.push(actLine + " ".repeat(Math.max(0, 70 - actLine.length)) + "\u2502");
210
- if (task) {
211
- const taskLine = `\u2502${" ".repeat(16)}\u2502 Task: "${task.title.slice(0, 40)}" [${task.priority.toUpperCase()}]`;
212
- lines.push(taskLine + " ".repeat(Math.max(0, 70 - taskLine.length)) + "\u2502");
213
- }
214
- }
215
- if (i < emps.length - 1) {
216
- lines.push("\u251C" + "\u2500".repeat(16) + "\u253C" + "\u2500".repeat(52) + "\u2524");
217
- }
218
- }
219
- }
220
- lines.push("\u2514" + "\u2500".repeat(16) + "\u2534" + "\u2500".repeat(52) + "\u2518");
221
- lines.push("");
222
- }
223
- return lines.join("\n");
224
- }
225
- function formatStatusDeep(status, task, role) {
226
- const lines = [];
227
- const header = `${status.name} (${role}) \u2014 ${status.project ?? "unknown project"}`;
228
- lines.push(`\u250C\u2500 ${header} ${"\u2500".repeat(Math.max(0, 66 - header.length))}\u2510`);
229
- if (task) {
230
- const taskLine = `\u2502 Task: "${task.title.slice(0, 50)}" [${task.priority.toUpperCase()}]`;
231
- lines.push(taskLine + " ".repeat(Math.max(0, 70 - taskLine.length)) + "\u2502");
232
- lines.push("\u251C" + "\u2500".repeat(69) + "\u2524");
233
- }
234
- if (!status.hasWindow) {
235
- lines.push("\u2502 No tmux session" + " ".repeat(53) + "\u2502");
236
- } else if (status.rawLines && status.rawLines.length > 0) {
237
- lines.push("\u2502 Recent activity:" + " ".repeat(52) + "\u2502");
238
- for (const line of status.rawLines.slice(-10)) {
239
- const trimmed = line.slice(0, 65);
240
- const padded = `\u2502 ${trimmed}`;
241
- lines.push(padded + " ".repeat(Math.max(0, 70 - padded.length)) + "\u2502");
242
- }
243
- } else {
244
- lines.push("\u2502 Session active \u2014 no recent output" + " ".repeat(35) + "\u2502");
245
- }
246
- lines.push("\u2514" + "\u2500".repeat(69) + "\u2518");
247
- return lines.join("\n");
248
- }
249
- export {
250
- capturePaneLines,
251
- formatStatusAll,
252
- formatStatusDeep,
253
- formatTeamCondensed,
254
- getEmployeeStatuses,
255
- getPaneCwd,
256
- inTmux,
257
- listTmuxSessions,
258
- listTmuxWindows,
259
- parseActivity,
260
- parseContextPercentage
261
- };
@@ -1,83 +0,0 @@
1
- // src/lib/tmux-transport.ts
2
- import { execFileSync } from "child_process";
3
- var QUIET = {
4
- encoding: "utf8",
5
- stdio: ["pipe", "pipe", "pipe"]
6
- };
7
- var TmuxTransport = class {
8
- getMySession() {
9
- try {
10
- return execFileSync("tmux", ["display-message", "-p", "#{session_name}"], QUIET).trim() || null;
11
- } catch {
12
- return null;
13
- }
14
- }
15
- listSessions() {
16
- try {
17
- return execFileSync("tmux", ["list-sessions", "-F", "#{session_name}"], QUIET).trim().split("\n").filter(Boolean);
18
- } catch {
19
- return [];
20
- }
21
- }
22
- isAlive(target) {
23
- try {
24
- const sessions = this.listSessions();
25
- if (!sessions.includes(target)) return false;
26
- const paneStatus = execFileSync(
27
- "tmux",
28
- ["list-panes", "-t", target, "-F", "#{pane_dead}"],
29
- QUIET
30
- ).trim();
31
- return paneStatus !== "1";
32
- } catch {
33
- return false;
34
- }
35
- }
36
- sendKeys(target, keys) {
37
- execFileSync("tmux", ["send-keys", "-t", target, keys, "Enter"], QUIET);
38
- }
39
- capturePane(target, lines) {
40
- const args = ["capture-pane", "-t", target, "-p"];
41
- if (lines) args.push("-S", `-${lines}`);
42
- return execFileSync("tmux", args, { ...QUIET, timeout: 3e3 });
43
- }
44
- isPaneInCopyMode(target) {
45
- try {
46
- const result = execFileSync(
47
- "tmux",
48
- ["display-message", "-p", "-t", target, "#{pane_in_mode}"],
49
- { ...QUIET, timeout: 3e3 }
50
- ).trim();
51
- return result === "1";
52
- } catch {
53
- return false;
54
- }
55
- }
56
- spawn(name, config) {
57
- try {
58
- const args = ["new-session", "-d", "-s", name];
59
- if (config.cwd) args.push("-c", config.cwd);
60
- args.push(config.command);
61
- execFileSync("tmux", args);
62
- return { sessionName: name };
63
- } catch (e) {
64
- return { sessionName: name, error: `spawn failed: ${e}` };
65
- }
66
- }
67
- kill(target) {
68
- try {
69
- execFileSync("tmux", ["kill-session", "-t", target], QUIET);
70
- } catch {
71
- }
72
- }
73
- pipeLog(target, logFile) {
74
- try {
75
- const safePath = logFile.replace(/'/g, "'\\''");
76
- execFileSync("tmux", ["pipe-pane", "-t", target, `cat >> '${safePath}'`], QUIET);
77
- } catch {
78
- }
79
- }
80
- };
81
- export {
82
- TmuxTransport
83
- };
@@ -1,128 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __esm = (fn, res) => function __init() {
6
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
- };
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/lib/tmux-transport.ts
23
- var tmux_transport_exports = {};
24
- __export(tmux_transport_exports, {
25
- TmuxTransport: () => TmuxTransport
26
- });
27
- import { execFileSync } from "child_process";
28
- var QUIET, TmuxTransport;
29
- var init_tmux_transport = __esm({
30
- "src/lib/tmux-transport.ts"() {
31
- "use strict";
32
- QUIET = {
33
- encoding: "utf8",
34
- stdio: ["pipe", "pipe", "pipe"]
35
- };
36
- TmuxTransport = class {
37
- getMySession() {
38
- try {
39
- return execFileSync("tmux", ["display-message", "-p", "#{session_name}"], QUIET).trim() || null;
40
- } catch {
41
- return null;
42
- }
43
- }
44
- listSessions() {
45
- try {
46
- return execFileSync("tmux", ["list-sessions", "-F", "#{session_name}"], QUIET).trim().split("\n").filter(Boolean);
47
- } catch {
48
- return [];
49
- }
50
- }
51
- isAlive(target) {
52
- try {
53
- const sessions = this.listSessions();
54
- if (!sessions.includes(target)) return false;
55
- const paneStatus = execFileSync(
56
- "tmux",
57
- ["list-panes", "-t", target, "-F", "#{pane_dead}"],
58
- QUIET
59
- ).trim();
60
- return paneStatus !== "1";
61
- } catch {
62
- return false;
63
- }
64
- }
65
- sendKeys(target, keys) {
66
- execFileSync("tmux", ["send-keys", "-t", target, keys, "Enter"], QUIET);
67
- }
68
- capturePane(target, lines) {
69
- const args = ["capture-pane", "-t", target, "-p"];
70
- if (lines) args.push("-S", `-${lines}`);
71
- return execFileSync("tmux", args, { ...QUIET, timeout: 3e3 });
72
- }
73
- isPaneInCopyMode(target) {
74
- try {
75
- const result = execFileSync(
76
- "tmux",
77
- ["display-message", "-p", "-t", target, "#{pane_in_mode}"],
78
- { ...QUIET, timeout: 3e3 }
79
- ).trim();
80
- return result === "1";
81
- } catch {
82
- return false;
83
- }
84
- }
85
- spawn(name, config) {
86
- try {
87
- const args = ["new-session", "-d", "-s", name];
88
- if (config.cwd) args.push("-c", config.cwd);
89
- args.push(config.command);
90
- execFileSync("tmux", args);
91
- return { sessionName: name };
92
- } catch (e) {
93
- return { sessionName: name, error: `spawn failed: ${e}` };
94
- }
95
- }
96
- kill(target) {
97
- try {
98
- execFileSync("tmux", ["kill-session", "-t", target], QUIET);
99
- } catch {
100
- }
101
- }
102
- pipeLog(target, logFile) {
103
- try {
104
- const safePath = logFile.replace(/'/g, "'\\''");
105
- execFileSync("tmux", ["pipe-pane", "-t", target, `cat >> '${safePath}'`], QUIET);
106
- } catch {
107
- }
108
- }
109
- };
110
- }
111
- });
112
-
113
- // src/lib/transport.ts
114
- var _transport = null;
115
- function getTransport() {
116
- if (!_transport) {
117
- const { TmuxTransport: TmuxTransport2 } = (init_tmux_transport(), __toCommonJS(tmux_transport_exports));
118
- _transport = new TmuxTransport2();
119
- }
120
- return _transport;
121
- }
122
- function setTransport(t) {
123
- _transport = t;
124
- }
125
- export {
126
- getTransport,
127
- setTransport
128
- };
@@ -1,19 +0,0 @@
1
- // src/lib/ws-auth.ts
2
- import crypto from "crypto";
3
- var WS_AUTH_HKDF_INFO = "exe-os-ws-auth-v1";
4
- var ORG_ID_HKDF_INFO = "exe-os-org-id-v1";
5
- function deriveWsAuthToken(masterKey) {
6
- return Buffer.from(crypto.hkdfSync("sha256", masterKey, "", WS_AUTH_HKDF_INFO, 32));
7
- }
8
- function deriveOrgId(masterKey) {
9
- const raw = Buffer.from(crypto.hkdfSync("sha256", masterKey, "", ORG_ID_HKDF_INFO, 32));
10
- return crypto.createHash("sha256").update(raw).digest("hex").slice(0, 32);
11
- }
12
- function hashAuthToken(token) {
13
- return crypto.createHash("sha256").update(token).digest("hex");
14
- }
15
- export {
16
- deriveOrgId,
17
- deriveWsAuthToken,
18
- hashAuthToken
19
- };
@@ -1,160 +0,0 @@
1
- // src/lib/message-queue.ts
2
- var DEFAULT_TTL_MS = 5 * 60 * 1e3;
3
-
4
- // src/lib/gateway-client.ts
5
- var LOCALHOST_PATTERNS = /^(localhost|127\.0\.0\.1|\[::1\])$/i;
6
- function assertSecureWsUrl(url) {
7
- if (url.startsWith("wss://")) return;
8
- if (url.startsWith("ws://")) {
9
- let parsed;
10
- try {
11
- parsed = new URL(url);
12
- } catch {
13
- throw new Error(
14
- `Malformed WebSocket URL rejected: "${url}".`
15
- );
16
- }
17
- if (LOCALHOST_PATTERNS.test(parsed.hostname)) return;
18
- throw new Error(
19
- `Insecure WebSocket URL rejected: "${url}". Use wss:// for remote hosts. Plain ws:// is only allowed for localhost.`
20
- );
21
- }
22
- }
23
-
24
- // src/lib/ws-client.ts
25
- var MIN_RECONNECT_MS = 1e3;
26
- var MAX_RECONNECT_MS = 3e4;
27
- var HEARTBEAT_INTERVAL_MS = 3e4;
28
- function createWsClient(config, handlers) {
29
- assertSecureWsUrl(config.endpoint);
30
- let ws = null;
31
- let connected = false;
32
- let closed = false;
33
- let reconnectDelay = MIN_RECONNECT_MS;
34
- let reconnectTimer = null;
35
- let heartbeatTimer = null;
36
- let currentAgents = [];
37
- let currentProjects = [];
38
- function connect() {
39
- if (closed) return;
40
- try {
41
- const url = `${config.endpoint}?org=${config.orgId}`;
42
- ws = new WebSocket(url, {
43
- headers: {
44
- Authorization: `Bearer ${config.authToken.toString("base64")}`
45
- }
46
- });
47
- ws.onopen = () => {
48
- connected = true;
49
- reconnectDelay = MIN_RECONNECT_MS;
50
- handlers.onConnect();
51
- sendRaw({
52
- type: "register",
53
- deviceId: config.deviceInfo.deviceId,
54
- friendlyName: config.deviceInfo.friendlyName,
55
- hostname: config.deviceInfo.hostname,
56
- agents: currentAgents,
57
- projects: currentProjects
58
- });
59
- if (heartbeatTimer) clearInterval(heartbeatTimer);
60
- heartbeatTimer = setInterval(() => {
61
- if (connected && ws?.readyState === WebSocket.OPEN) {
62
- sendRaw({ type: "ping" });
63
- }
64
- }, HEARTBEAT_INTERVAL_MS);
65
- };
66
- ws.onmessage = (event) => {
67
- try {
68
- const data = typeof event.data === "string" ? event.data : String(event.data);
69
- const msg = JSON.parse(data);
70
- switch (msg.type) {
71
- case "deliver":
72
- if (msg.payload) handlers.onMessage(msg.payload);
73
- break;
74
- case "registry":
75
- if (msg.devices) handlers.onRegistry(msg.devices);
76
- break;
77
- }
78
- } catch {
79
- }
80
- };
81
- ws.onclose = () => {
82
- connected = false;
83
- if (heartbeatTimer) {
84
- clearInterval(heartbeatTimer);
85
- heartbeatTimer = null;
86
- }
87
- handlers.onDisconnect();
88
- scheduleReconnect();
89
- };
90
- ws.onerror = () => {
91
- };
92
- } catch {
93
- connected = false;
94
- scheduleReconnect();
95
- }
96
- }
97
- function sendRaw(data) {
98
- if (ws?.readyState === WebSocket.OPEN) {
99
- try {
100
- ws.send(JSON.stringify(data));
101
- } catch {
102
- }
103
- }
104
- }
105
- function scheduleReconnect() {
106
- if (closed || reconnectTimer) return;
107
- reconnectTimer = setTimeout(() => {
108
- reconnectTimer = null;
109
- reconnectDelay = Math.min(reconnectDelay * 2, MAX_RECONNECT_MS);
110
- connect();
111
- }, reconnectDelay);
112
- }
113
- connect();
114
- return {
115
- send(targetDevice, payload) {
116
- if (!connected || ws?.readyState !== WebSocket.OPEN) return false;
117
- sendRaw({ type: "message", targetDevice, payload });
118
- return true;
119
- },
120
- updateRegistration(agents, projects) {
121
- currentAgents = agents;
122
- currentProjects = projects;
123
- if (connected) {
124
- sendRaw({
125
- type: "register",
126
- deviceId: config.deviceInfo.deviceId,
127
- friendlyName: config.deviceInfo.friendlyName,
128
- hostname: config.deviceInfo.hostname,
129
- agents,
130
- projects
131
- });
132
- }
133
- },
134
- close() {
135
- closed = true;
136
- if (reconnectTimer) {
137
- clearTimeout(reconnectTimer);
138
- reconnectTimer = null;
139
- }
140
- if (heartbeatTimer) {
141
- clearInterval(heartbeatTimer);
142
- heartbeatTimer = null;
143
- }
144
- if (ws) {
145
- try {
146
- ws.close();
147
- } catch {
148
- }
149
- ws = null;
150
- }
151
- connected = false;
152
- },
153
- isConnected() {
154
- return connected;
155
- }
156
- };
157
- }
158
- export {
159
- createWsClient
160
- };