@askexenow/exe-os 0.8.0 → 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 (107) hide show
  1. package/README.md +178 -79
  2. package/package.json +1 -1
  3. package/dist/bin/backfill-responses.js +0 -1912
  4. package/dist/bin/backfill-vectors.js +0 -1642
  5. package/dist/bin/cleanup-stale-review-tasks.js +0 -1339
  6. package/dist/bin/cli.js +0 -18800
  7. package/dist/bin/exe-agent.js +0 -1858
  8. package/dist/bin/exe-assign.js +0 -1957
  9. package/dist/bin/exe-boot.js +0 -6460
  10. package/dist/bin/exe-call.js +0 -197
  11. package/dist/bin/exe-cloud.js +0 -850
  12. package/dist/bin/exe-dispatch.js +0 -1146
  13. package/dist/bin/exe-doctor.js +0 -1657
  14. package/dist/bin/exe-export-behaviors.js +0 -1494
  15. package/dist/bin/exe-forget.js +0 -1627
  16. package/dist/bin/exe-gateway.js +0 -7732
  17. package/dist/bin/exe-healthcheck.js +0 -207
  18. package/dist/bin/exe-heartbeat.js +0 -1647
  19. package/dist/bin/exe-kill.js +0 -1479
  20. package/dist/bin/exe-launch-agent.js +0 -1704
  21. package/dist/bin/exe-link.js +0 -192
  22. package/dist/bin/exe-new-employee.js +0 -852
  23. package/dist/bin/exe-pending-messages.js +0 -1446
  24. package/dist/bin/exe-pending-notifications.js +0 -1321
  25. package/dist/bin/exe-pending-reviews.js +0 -1468
  26. package/dist/bin/exe-repo-drift.js +0 -95
  27. package/dist/bin/exe-review.js +0 -1590
  28. package/dist/bin/exe-search.js +0 -2651
  29. package/dist/bin/exe-session-cleanup.js +0 -3173
  30. package/dist/bin/exe-settings.js +0 -354
  31. package/dist/bin/exe-status.js +0 -1532
  32. package/dist/bin/exe-team.js +0 -1324
  33. package/dist/bin/git-sweep.js +0 -2185
  34. package/dist/bin/graph-backfill.js +0 -1968
  35. package/dist/bin/graph-export.js +0 -1604
  36. package/dist/bin/install.js +0 -656
  37. package/dist/bin/list-providers.js +0 -140
  38. package/dist/bin/scan-tasks.js +0 -1820
  39. package/dist/bin/setup.js +0 -951
  40. package/dist/bin/shard-migrate.js +0 -1494
  41. package/dist/bin/update.js +0 -95
  42. package/dist/bin/wiki-sync.js +0 -1514
  43. package/dist/gateway/index.js +0 -8848
  44. package/dist/hooks/bug-report-worker.js +0 -2743
  45. package/dist/hooks/commit-complete.js +0 -2108
  46. package/dist/hooks/error-recall.js +0 -2861
  47. package/dist/hooks/exe-heartbeat-hook.js +0 -232
  48. package/dist/hooks/ingest-worker.js +0 -4793
  49. package/dist/hooks/ingest.js +0 -684
  50. package/dist/hooks/instructions-loaded.js +0 -1880
  51. package/dist/hooks/notification.js +0 -1726
  52. package/dist/hooks/post-compact.js +0 -1751
  53. package/dist/hooks/pre-compact.js +0 -1746
  54. package/dist/hooks/pre-tool-use.js +0 -2191
  55. package/dist/hooks/prompt-ingest-worker.js +0 -2126
  56. package/dist/hooks/prompt-submit.js +0 -4693
  57. package/dist/hooks/response-ingest-worker.js +0 -1936
  58. package/dist/hooks/session-end.js +0 -1752
  59. package/dist/hooks/session-start.js +0 -2795
  60. package/dist/hooks/stop.js +0 -1835
  61. package/dist/hooks/subagent-stop.js +0 -1726
  62. package/dist/hooks/summary-worker.js +0 -2661
  63. package/dist/index.js +0 -11834
  64. package/dist/lib/cloud-sync.js +0 -495
  65. package/dist/lib/config.js +0 -222
  66. package/dist/lib/consolidation.js +0 -476
  67. package/dist/lib/crypto.js +0 -51
  68. package/dist/lib/database.js +0 -730
  69. package/dist/lib/device-registry.js +0 -900
  70. package/dist/lib/embedder.js +0 -632
  71. package/dist/lib/employee-templates.js +0 -543
  72. package/dist/lib/employees.js +0 -177
  73. package/dist/lib/error-detector.js +0 -156
  74. package/dist/lib/exe-daemon-client.js +0 -451
  75. package/dist/lib/exe-daemon.js +0 -8285
  76. package/dist/lib/file-grep.js +0 -199
  77. package/dist/lib/hybrid-search.js +0 -1819
  78. package/dist/lib/identity-templates.js +0 -320
  79. package/dist/lib/identity.js +0 -223
  80. package/dist/lib/keychain.js +0 -145
  81. package/dist/lib/license.js +0 -377
  82. package/dist/lib/messaging.js +0 -1376
  83. package/dist/lib/reminders.js +0 -63
  84. package/dist/lib/schedules.js +0 -1396
  85. package/dist/lib/session-registry.js +0 -52
  86. package/dist/lib/skill-learning.js +0 -477
  87. package/dist/lib/status-brief.js +0 -235
  88. package/dist/lib/store.js +0 -1551
  89. package/dist/lib/task-router.js +0 -62
  90. package/dist/lib/tasks.js +0 -2456
  91. package/dist/lib/tmux-routing.js +0 -2836
  92. package/dist/lib/tmux-status.js +0 -261
  93. package/dist/lib/tmux-transport.js +0 -83
  94. package/dist/lib/transport.js +0 -128
  95. package/dist/lib/ws-auth.js +0 -19
  96. package/dist/lib/ws-client.js +0 -160
  97. package/dist/mcp/server.js +0 -10538
  98. package/dist/mcp/tools/complete-reminder.js +0 -67
  99. package/dist/mcp/tools/create-reminder.js +0 -52
  100. package/dist/mcp/tools/create-task.js +0 -1853
  101. package/dist/mcp/tools/deactivate-behavior.js +0 -263
  102. package/dist/mcp/tools/list-reminders.js +0 -62
  103. package/dist/mcp/tools/list-tasks.js +0 -463
  104. package/dist/mcp/tools/send-message.js +0 -1382
  105. package/dist/mcp/tools/update-task.js +0 -1692
  106. package/dist/runtime/index.js +0 -6809
  107. package/dist/tui/App.js +0 -17479
@@ -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
- };