@triflux/remote 10.51.0 → 10.53.0

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 (62) hide show
  1. package/cto/brief.mjs +0 -8
  2. package/cto/collect.mjs +1 -127
  3. package/cto/current.schema.json +2 -19
  4. package/cto/hygiene.mjs +2 -61
  5. package/cto/lake-root.mjs +0 -56
  6. package/cto/status.mjs +5 -139
  7. package/hub/index.mjs +0 -9
  8. package/hub/team/agents-row-attach.py +120 -0
  9. package/hub/team/agents-row.mjs +200 -0
  10. package/hub/team/claude-daemon-control.mjs +1 -2
  11. package/hub/team/claude-session-projection.mjs +5 -73
  12. package/hub/team/claude-transcript.mjs +19 -0
  13. package/hub/team/cli/commands/debug.mjs +1 -2
  14. package/hub/team/cli/commands/start/index.mjs +2 -1
  15. package/hub/team/cli/commands/start/start-headless.mjs +2 -0
  16. package/hub/team/cli/commands/start/start-mux.mjs +2 -4
  17. package/hub/team/cli/services/state-store.mjs +5 -20
  18. package/hub/team/headless.mjs +132 -551
  19. package/hub/team/psmux.mjs +3 -33
  20. package/hub/team/results-index.mjs +92 -0
  21. package/hub/team/session-context.mjs +1 -1
  22. package/hub/team/tui-viewer.mjs +9 -56
  23. package/hub/team/tui.mjs +0 -37
  24. package/hub/team/uds-orchestrator.mjs +20 -599
  25. package/hub/workers/factory.mjs +6 -51
  26. package/hub/workers/interface.mjs +1 -7
  27. package/hub/workers/lib/jsonrpc-core.mjs +11 -0
  28. package/hub/workers/lib/jsonrpc-ws-uds.mjs +5 -6
  29. package/package.json +3 -8
  30. package/scripts/lib/agent-route-policy.mjs +0 -67
  31. package/scripts/lib/cli-claude.mjs +0 -12
  32. package/scripts/lib/env-probe.mjs +0 -70
  33. package/scripts/lib/legacy-mcp-cleanup.mjs +283 -0
  34. package/scripts/lib/mcp-guard-engine.mjs +42 -101
  35. package/hub/hub-lifecycle.mjs +0 -248
  36. package/hub/pipe.mjs +0 -825
  37. package/hub/promote-penalties.mjs +0 -138
  38. package/hub/public/dashboard.html +0 -416
  39. package/hub/schema.sql +0 -209
  40. package/hub/server.mjs +0 -3048
  41. package/hub/store-adapter.mjs +0 -182
  42. package/hub/store.mjs +0 -1736
  43. package/hub/team/cli/services/hub-client.mjs +0 -178
  44. package/hub/team/conductor-registry.mjs +0 -121
  45. package/hub/team/cto-auto-collect.mjs +0 -115
  46. package/hub/team/lead-control.mjs +0 -191
  47. package/hub/team/session-sync.mjs +0 -316
  48. package/hub/team/swarm-intent.mjs +0 -18
  49. package/hub/team/synapse-cli.mjs +0 -458
  50. package/hub/team/synapse-http.mjs +0 -311
  51. package/hub/team/synapse-registry.mjs +0 -618
  52. package/hub/team/tui-synapse.mjs +0 -223
  53. package/hub/team/worker-sandbox.mjs +0 -125
  54. package/hub/tools.mjs +0 -900
  55. package/hub/workers/codex-app-server-worker.mjs +0 -1067
  56. package/hub/workers/delegator-mcp.mjs +0 -1098
  57. package/hub/workers/lib/jsonrpc-stdio.mjs +0 -204
  58. package/scripts/lib/claudemd-scanner.mjs +0 -26
  59. package/scripts/lib/context.mjs +0 -51
  60. package/scripts/lib/handoff.mjs +0 -187
  61. package/scripts/lib/logger.mjs +0 -122
  62. package/scripts/lib/stealth-fetch.mjs +0 -176
@@ -1,248 +0,0 @@
1
- // hub/hub-lifecycle.mjs — Hub process lifecycle helpers
2
-
3
- import { execFileSync } from "node:child_process";
4
- import { readFileSync } from "node:fs";
5
- import { homedir } from "node:os";
6
- import { join } from "node:path";
7
-
8
- export const HUB_DEFAULT_PORT = 27888;
9
-
10
- const HUB_PID_FILE = join(homedir(), ".claude", "cache", "tfx-hub", "hub.pid");
11
- const EPHEMERAL_ENV_KEYS = [
12
- "TFX_WORKER_SANDBOX_SCOPE",
13
- "TFX_WORKER_INDEX",
14
- "TFX_TEAM_TASK_ID",
15
- "TFX_TEAM_AGENT_NAME",
16
- "TFX_EPHEMERAL",
17
- ];
18
- const WORKTREE_CWD_PATTERNS = [
19
- /\/\.claude\/worktrees\//u,
20
- /\/\.worktrees\//u,
21
- /\/\.codex-swarm\/wt-[^/]+(?:\/|$)/u,
22
- /(^|\/)wt-[^/]+(?:\/|$)/u,
23
- ];
24
-
25
- function parsePositivePort(value) {
26
- const parsed = Number.parseInt(String(value ?? ""), 10);
27
- return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
28
- }
29
-
30
- function parsePortFromHubUrl(value) {
31
- try {
32
- return parsePositivePort(new URL(String(value)).port);
33
- } catch {
34
- return null;
35
- }
36
- }
37
-
38
- export function isHubServerCommand(command) {
39
- return /(^|[\\/,\s])hub[\\/]server\.mjs(?=$|[\s"'`])/i.test(
40
- String(command || ""),
41
- );
42
- }
43
-
44
- export function isWorktreeOrEphemeralHubContext({
45
- cwd = process.cwd(),
46
- env = process.env,
47
- } = {}) {
48
- const normalizedCwd = String(cwd || "").replace(/\\/g, "/");
49
- if (WORKTREE_CWD_PATTERNS.some((pattern) => pattern.test(normalizedCwd))) {
50
- return true;
51
- }
52
- return EPHEMERAL_ENV_KEYS.some((key) => String(env?.[key] || "").length > 0);
53
- }
54
-
55
- export function resolveHubPortForContext({
56
- port,
57
- env = process.env,
58
- cwd = process.cwd(),
59
- defaultPort = HUB_DEFAULT_PORT,
60
- } = {}) {
61
- const envPort =
62
- parsePositivePort(port) ?? parsePositivePort(env?.TFX_HUB_PORT);
63
- const urlPort = parsePortFromHubUrl(env?.TFX_HUB_URL);
64
- const resolvedPort = envPort ?? urlPort ?? defaultPort;
65
- if (
66
- resolvedPort !== defaultPort &&
67
- // Test-only opt-in seam: TFX_HUB_ALLOW_EPHEMERAL_PORT=1 lets an ephemeral
68
- // context (worktree cwd / TFX_TEAM_* env) honor the resolved port instead
69
- // of clamping to the canonical default. Default-off — production unchanged.
70
- String(env?.TFX_HUB_ALLOW_EPHEMERAL_PORT ?? "") !== "1" &&
71
- isWorktreeOrEphemeralHubContext({ cwd, env })
72
- ) {
73
- return defaultPort;
74
- }
75
- return resolvedPort;
76
- }
77
-
78
- export function collectHubProcesses(
79
- psOutput = "",
80
- { currentPid = process.pid } = {},
81
- ) {
82
- const ownPid = Number(currentPid);
83
- return String(psOutput)
84
- .split(/\r?\n/u)
85
- .flatMap((line) => {
86
- const match = line.match(/^\s*(\d+)\s+(\d+)\s+(.+)$/u);
87
- if (!match) return [];
88
- const pid = Number.parseInt(match[1], 10);
89
- const ppid = Number.parseInt(match[2], 10);
90
- const command = match[3].trim();
91
- if (!Number.isFinite(pid) || pid === ownPid) return [];
92
- if (!/\bnode(?:\s|$)|\/node(?:\s|$)/u.test(command)) return [];
93
- if (!isHubServerCommand(command)) return [];
94
- return [{ pid, ppid, command }];
95
- });
96
- }
97
-
98
- function readPidFilePid({
99
- pidFilePath = HUB_PID_FILE,
100
- readFile = readFileSync,
101
- } = {}) {
102
- try {
103
- const info = JSON.parse(readFile(pidFilePath, "utf8"));
104
- const pid = Number(info?.pid);
105
- return Number.isFinite(pid) && pid > 0 ? pid : null;
106
- } catch {
107
- return null;
108
- }
109
- }
110
-
111
- function findListeningPidsForPort(
112
- port = HUB_DEFAULT_PORT,
113
- { execFileSyncFn = execFileSync } = {},
114
- ) {
115
- try {
116
- const output = execFileSyncFn(
117
- "lsof",
118
- ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"],
119
- {
120
- encoding: "utf8",
121
- timeout: 1000,
122
- maxBuffer: 1024 * 1024,
123
- },
124
- );
125
- return String(output)
126
- .split(/\r?\n/u)
127
- .map((line) => Number.parseInt(line.trim(), 10))
128
- .filter((pid) => Number.isFinite(pid) && pid > 0);
129
- } catch {
130
- return [];
131
- }
132
- }
133
-
134
- async function waitForExit(
135
- pid,
136
- { killFn = process.kill, graceMs = 5000, pollMs = 100 } = {},
137
- ) {
138
- const deadline = Date.now() + Math.max(0, graceMs);
139
- while (Date.now() <= deadline) {
140
- try {
141
- killFn(pid, 0);
142
- } catch {
143
- return true;
144
- }
145
- await new Promise((resolve) => setTimeout(resolve, pollMs));
146
- }
147
- try {
148
- killFn(pid, 0);
149
- return false;
150
- } catch {
151
- return true;
152
- }
153
- }
154
-
155
- export async function reapExistingHubProcesses({
156
- currentPid = process.pid,
157
- pidFilePath = HUB_PID_FILE,
158
- execFileSyncFn = execFileSync,
159
- killFn = process.kill,
160
- readPidFileFn,
161
- findListeningPidsForPortFn,
162
- waitForExitFn,
163
- graceMs = 5000,
164
- pollMs = 100,
165
- } = {}) {
166
- let output = "";
167
- try {
168
- output = execFileSyncFn("ps", ["-axo", "pid,ppid,command"], {
169
- encoding: "utf8",
170
- timeout: 1000,
171
- maxBuffer: 1024 * 1024,
172
- });
173
- } catch {
174
- return {
175
- candidates: [],
176
- reaped: [],
177
- preserved: {
178
- currentPid: Number(currentPid),
179
- pidFilePid: null,
180
- defaultPortPids: [],
181
- },
182
- };
183
- }
184
-
185
- const current = Number(currentPid);
186
- const pidFileInfo =
187
- typeof readPidFileFn === "function"
188
- ? readPidFileFn()
189
- : { pid: readPidFilePid({ pidFilePath }) };
190
- const pidFilePid = parsePositivePort(pidFileInfo?.pid);
191
- const defaultPortPids = [
192
- ...new Set(
193
- (typeof findListeningPidsForPortFn === "function"
194
- ? findListeningPidsForPortFn(HUB_DEFAULT_PORT)
195
- : findListeningPidsForPort(HUB_DEFAULT_PORT, { execFileSyncFn })
196
- ).map(Number),
197
- ),
198
- ].filter((pid) => Number.isFinite(pid) && pid > 0);
199
-
200
- const preservedPids = new Set(
201
- [current, pidFilePid, ...defaultPortPids].filter(
202
- (pid) => Number.isFinite(pid) && pid > 0,
203
- ),
204
- );
205
- const candidates = collectHubProcesses(output, { currentPid: current });
206
- const reaped = [];
207
- const failed = [];
208
-
209
- for (const processInfo of candidates) {
210
- if (preservedPids.has(processInfo.pid)) continue;
211
- try {
212
- killFn(processInfo.pid, "SIGTERM");
213
- const exited =
214
- typeof waitForExitFn === "function"
215
- ? await waitForExitFn(processInfo.pid, { killFn, graceMs, pollMs })
216
- : await waitForExit(processInfo.pid, { killFn, graceMs, pollMs });
217
- if (!exited) {
218
- try {
219
- killFn(processInfo.pid, "SIGKILL");
220
- } catch (error) {
221
- failed.push({
222
- pid: processInfo.pid,
223
- signal: "SIGKILL",
224
- error: String(error?.message || error),
225
- });
226
- }
227
- }
228
- reaped.push(processInfo);
229
- } catch (error) {
230
- failed.push({
231
- pid: processInfo.pid,
232
- signal: "SIGTERM",
233
- error: String(error?.message || error),
234
- });
235
- }
236
- }
237
-
238
- return {
239
- candidates,
240
- reaped,
241
- failed,
242
- preserved: {
243
- currentPid: current,
244
- pidFilePid,
245
- defaultPortPids,
246
- },
247
- };
248
- }