triflux 8.11.2 → 8.12.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/hooks/hooks.json +56 -51
- package/hub/pipeline/index.mjs +318 -318
- package/hub/routing/q-learning.mjs +2 -1
- package/hub/schema.sql +146 -146
- package/hub/team/cli/commands/kill.mjs +37 -37
- package/hub/team/cli/commands/start/index.mjs +3 -2
- package/hub/team/cli/commands/start/parse-args.mjs +5 -0
- package/hub/team/cli/commands/start/start-headless.mjs +2 -1
- package/hub/team/cli/commands/stop.mjs +31 -31
- package/hub/team/cli/commands/task.mjs +30 -30
- package/hub/team/cli/help.mjs +41 -40
- package/hub/team/cli/services/hub-client.mjs +208 -208
- package/hub/team/cli/services/native-control.mjs +118 -118
- package/hub/team/cli/services/runtime-mode.mjs +62 -62
- package/hub/team/cli/services/state-store.mjs +48 -48
- package/hub/team/dashboard-anchor.mjs +14 -0
- package/hub/team/dashboard.mjs +274 -274
- package/hub/team/headless.mjs +44 -19
- package/hub/team/native.mjs +649 -649
- package/hub/tools.mjs +554 -554
- package/hub/workers/delegator-mcp.mjs +21 -1
- package/package.json +1 -1
- package/scripts/__tests__/remote-spawn-transfer.test.mjs +117 -0
- package/scripts/__tests__/remote-spawn.test.mjs +78 -0
- package/scripts/cache-buildup.mjs +401 -0
- package/scripts/headless-guard.mjs +10 -3
- package/scripts/hub-ensure.mjs +120 -120
- package/scripts/lib/mcp-filter.mjs +720 -720
- package/scripts/lib/remote-spawn-transfer.mjs +196 -0
- package/scripts/mcp-check.mjs +237 -127
- package/scripts/mcp-gateway-ensure.mjs +6 -8
- package/scripts/mcp-gateway-integration-test.mjs +228 -0
- package/scripts/mcp-gateway-start.mjs +42 -16
- package/scripts/mcp-gateway-start.ps1 +17 -14
- package/scripts/mcp-gateway-verify.mjs +1 -1
- package/scripts/preflight-cache.mjs +137 -137
- package/scripts/remote-spawn.mjs +404 -40
- package/scripts/setup.mjs +18 -0
- package/scripts/tfx-route-worker.mjs +165 -165
- package/scripts/tfx-route.sh +85 -16
- package/scripts/token-snapshot.mjs +575 -575
- package/skills/tfx-analysis/SKILL.md +101 -101
- package/skills/tfx-autopilot/SKILL.md +112 -112
- package/skills/tfx-autoresearch/SKILL.md +1 -0
- package/skills/tfx-autoroute/SKILL.md +184 -184
- package/skills/tfx-codex-swarm/SKILL.md +449 -0
- package/skills/tfx-codex-swarm/evals/evals.json +26 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/benchmark.json +33 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/eval_metadata.json +42 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/grading.json +11 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/outputs/analysis.md +87 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/outputs/classification.md +35 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/outputs/commands.sh +275 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/outputs/routing.md +56 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/with_skill/timing.json +5 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/grading.json +11 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/outputs/analysis.md +92 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/outputs/classification.md +71 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/outputs/commands.sh +264 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/outputs/routing.md +113 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/full-swarm-all-prds/without_skill/timing.json +5 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/eval_metadata.json +32 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/grading.json +9 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/outputs/analysis.md +96 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/outputs/classification.md +38 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/outputs/commands.sh +151 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/outputs/routing.md +51 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/with_skill/timing.json +5 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/grading.json +9 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/outputs/analysis.md +127 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/outputs/classification.md +57 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/outputs/commands.sh +129 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/outputs/routing.md +84 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/implicit-swarm-no-keywords/without_skill/timing.json +5 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/eval_metadata.json +27 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/grading.json +8 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/outputs/analysis.md +98 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/outputs/classification.md +65 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/outputs/commands.sh +123 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/outputs/routing.md +66 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/with_skill/timing.json +5 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/grading.json +8 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/outputs/analysis.md +88 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/outputs/classification.md +40 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/outputs/commands.sh +130 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/outputs/routing.md +61 -0
- package/skills/tfx-codex-swarm-workspace/iteration-1/selective-spawn-with-override/without_skill/timing.json +5 -0
- package/skills/tfx-profile/SKILL.md +141 -51
- package/skills/tfx-qa/SKILL.md +117 -117
- package/skills/tfx-remote-spawn/references/hosts.json +16 -16
- package/skills/tfx-review/SKILL.md +51 -51
- package/skills/tfx-setup/SKILL.md +20 -0
- package/tui/gemini-profile.mjs +254 -0
- package/tui/setup.mjs +36 -1
- package/scripts/claude-logged.ps1 +0 -54
- package/scripts/demo-tui.mjs +0 -59
- package/skills/.omc/state/agent-replay-8f0e10a9-9693-4410-96f5-a6b07e8ed995.jsonl +0 -1
- package/skills/.omc/state/idle-notif-cooldown.json +0 -3
- package/skills/.omc/state/last-tool-error.json +0 -7
- package/skills/.omc/state/subagent-tracking.json +0 -7
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
|
-
|
|
5
|
-
import { buildLeadPrompt, buildPrompt } from "../../orchestrator.mjs";
|
|
6
|
-
import { HUB_PID_DIR, PKG_ROOT } from "./state-store.mjs";
|
|
7
|
-
import { FEATURES } from "../../codex-compat.mjs";
|
|
8
|
-
|
|
9
|
-
export function buildNativeCliCommand(cli) {
|
|
10
|
-
switch (cli) {
|
|
11
|
-
case "codex":
|
|
12
|
-
return FEATURES.execSubcommand
|
|
13
|
-
? "codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check"
|
|
14
|
-
: "codex --dangerously-bypass-approvals-and-sandbox";
|
|
15
|
-
case "gemini":
|
|
16
|
-
return "gemini";
|
|
17
|
-
case "claude":
|
|
18
|
-
return "claude";
|
|
19
|
-
default:
|
|
20
|
-
return cli;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function startNativeSupervisor({ sessionId, task, lead, agents, subtasks, hubUrl }) {
|
|
25
|
-
const configPath = join(HUB_PID_DIR, `team-native-${sessionId}.config.json`);
|
|
26
|
-
const runtimePath = join(HUB_PID_DIR, `team-native-${sessionId}.runtime.json`);
|
|
27
|
-
const logsDir = join(HUB_PID_DIR, "team-logs", sessionId);
|
|
28
|
-
mkdirSync(logsDir, { recursive: true });
|
|
29
|
-
|
|
30
|
-
const leadMember = {
|
|
31
|
-
role: "lead",
|
|
32
|
-
name: "lead",
|
|
33
|
-
cli: lead,
|
|
34
|
-
agentId: `${lead}-lead`,
|
|
35
|
-
command: buildNativeCliCommand(lead),
|
|
36
|
-
};
|
|
37
|
-
const workers = agents.map((cli, index) => ({
|
|
38
|
-
role: "worker",
|
|
39
|
-
name: `${cli}-${index + 1}`,
|
|
40
|
-
cli,
|
|
41
|
-
agentId: `${cli}-w${index + 1}`,
|
|
42
|
-
command: buildNativeCliCommand(cli),
|
|
43
|
-
subtask: subtasks[index],
|
|
44
|
-
}));
|
|
45
|
-
const members = [
|
|
46
|
-
{
|
|
47
|
-
...leadMember,
|
|
48
|
-
prompt: buildLeadPrompt(task, {
|
|
49
|
-
agentId: leadMember.agentId,
|
|
50
|
-
hubUrl,
|
|
51
|
-
teammateMode: "in-process",
|
|
52
|
-
workers: workers.map((worker) => ({
|
|
53
|
-
agentId: worker.agentId,
|
|
54
|
-
cli: worker.cli,
|
|
55
|
-
subtask: worker.subtask,
|
|
56
|
-
})),
|
|
57
|
-
}),
|
|
58
|
-
},
|
|
59
|
-
...workers.map((worker) => ({
|
|
60
|
-
...worker,
|
|
61
|
-
prompt: buildPrompt(worker.subtask, { cli: worker.cli, agentId: worker.agentId, hubUrl }),
|
|
62
|
-
})),
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
writeFileSync(configPath, JSON.stringify({
|
|
66
|
-
sessionName: sessionId,
|
|
67
|
-
hubUrl,
|
|
68
|
-
startupDelayMs: 3000,
|
|
69
|
-
logsDir,
|
|
70
|
-
runtimeFile: runtimePath,
|
|
71
|
-
members,
|
|
72
|
-
}, null, 2) + "\n");
|
|
73
|
-
|
|
74
|
-
const child = spawn(process.execPath, [join(PKG_ROOT, "hub", "team", "native-supervisor.mjs"), "--config", configPath], {
|
|
75
|
-
detached: true,
|
|
76
|
-
stdio: "ignore",
|
|
77
|
-
env: { ...process.env },
|
|
78
|
-
windowsHide: true,
|
|
79
|
-
});
|
|
80
|
-
child.unref();
|
|
81
|
-
|
|
82
|
-
const deadline = Date.now() + 5000;
|
|
83
|
-
while (Date.now() < deadline) {
|
|
84
|
-
if (existsSync(runtimePath)) {
|
|
85
|
-
try {
|
|
86
|
-
const runtime = JSON.parse(readFileSync(runtimePath, "utf8"));
|
|
87
|
-
return { runtime, members };
|
|
88
|
-
} catch {}
|
|
89
|
-
}
|
|
90
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return { runtime: null, members };
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function nativeRequest(state, path, body = {}) {
|
|
97
|
-
if (!state?.native?.controlUrl) return null;
|
|
98
|
-
try {
|
|
99
|
-
const res = await fetch(`${state.native.controlUrl}${path}`, {
|
|
100
|
-
method: "POST",
|
|
101
|
-
headers: { "Content-Type": "application/json" },
|
|
102
|
-
body: JSON.stringify(body),
|
|
103
|
-
});
|
|
104
|
-
return await res.json();
|
|
105
|
-
} catch {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export async function nativeGetStatus(state) {
|
|
111
|
-
if (!state?.native?.controlUrl) return null;
|
|
112
|
-
try {
|
|
113
|
-
const res = await fetch(`${state.native.controlUrl}/status`);
|
|
114
|
-
return await res.json();
|
|
115
|
-
} catch {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
|
|
5
|
+
import { buildLeadPrompt, buildPrompt } from "../../orchestrator.mjs";
|
|
6
|
+
import { HUB_PID_DIR, PKG_ROOT } from "./state-store.mjs";
|
|
7
|
+
import { FEATURES } from "../../codex-compat.mjs";
|
|
8
|
+
|
|
9
|
+
export function buildNativeCliCommand(cli) {
|
|
10
|
+
switch (cli) {
|
|
11
|
+
case "codex":
|
|
12
|
+
return FEATURES.execSubcommand
|
|
13
|
+
? "codex exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check"
|
|
14
|
+
: "codex --dangerously-bypass-approvals-and-sandbox";
|
|
15
|
+
case "gemini":
|
|
16
|
+
return "gemini";
|
|
17
|
+
case "claude":
|
|
18
|
+
return "claude";
|
|
19
|
+
default:
|
|
20
|
+
return cli;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function startNativeSupervisor({ sessionId, task, lead, agents, subtasks, hubUrl }) {
|
|
25
|
+
const configPath = join(HUB_PID_DIR, `team-native-${sessionId}.config.json`);
|
|
26
|
+
const runtimePath = join(HUB_PID_DIR, `team-native-${sessionId}.runtime.json`);
|
|
27
|
+
const logsDir = join(HUB_PID_DIR, "team-logs", sessionId);
|
|
28
|
+
mkdirSync(logsDir, { recursive: true });
|
|
29
|
+
|
|
30
|
+
const leadMember = {
|
|
31
|
+
role: "lead",
|
|
32
|
+
name: "lead",
|
|
33
|
+
cli: lead,
|
|
34
|
+
agentId: `${lead}-lead`,
|
|
35
|
+
command: buildNativeCliCommand(lead),
|
|
36
|
+
};
|
|
37
|
+
const workers = agents.map((cli, index) => ({
|
|
38
|
+
role: "worker",
|
|
39
|
+
name: `${cli}-${index + 1}`,
|
|
40
|
+
cli,
|
|
41
|
+
agentId: `${cli}-w${index + 1}`,
|
|
42
|
+
command: buildNativeCliCommand(cli),
|
|
43
|
+
subtask: subtasks[index],
|
|
44
|
+
}));
|
|
45
|
+
const members = [
|
|
46
|
+
{
|
|
47
|
+
...leadMember,
|
|
48
|
+
prompt: buildLeadPrompt(task, {
|
|
49
|
+
agentId: leadMember.agentId,
|
|
50
|
+
hubUrl,
|
|
51
|
+
teammateMode: "in-process",
|
|
52
|
+
workers: workers.map((worker) => ({
|
|
53
|
+
agentId: worker.agentId,
|
|
54
|
+
cli: worker.cli,
|
|
55
|
+
subtask: worker.subtask,
|
|
56
|
+
})),
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
...workers.map((worker) => ({
|
|
60
|
+
...worker,
|
|
61
|
+
prompt: buildPrompt(worker.subtask, { cli: worker.cli, agentId: worker.agentId, hubUrl }),
|
|
62
|
+
})),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
writeFileSync(configPath, JSON.stringify({
|
|
66
|
+
sessionName: sessionId,
|
|
67
|
+
hubUrl,
|
|
68
|
+
startupDelayMs: 3000,
|
|
69
|
+
logsDir,
|
|
70
|
+
runtimeFile: runtimePath,
|
|
71
|
+
members,
|
|
72
|
+
}, null, 2) + "\n");
|
|
73
|
+
|
|
74
|
+
const child = spawn(process.execPath, [join(PKG_ROOT, "hub", "team", "native-supervisor.mjs"), "--config", configPath], {
|
|
75
|
+
detached: true,
|
|
76
|
+
stdio: "ignore",
|
|
77
|
+
env: { ...process.env },
|
|
78
|
+
windowsHide: true,
|
|
79
|
+
});
|
|
80
|
+
child.unref();
|
|
81
|
+
|
|
82
|
+
const deadline = Date.now() + 5000;
|
|
83
|
+
while (Date.now() < deadline) {
|
|
84
|
+
if (existsSync(runtimePath)) {
|
|
85
|
+
try {
|
|
86
|
+
const runtime = JSON.parse(readFileSync(runtimePath, "utf8"));
|
|
87
|
+
return { runtime, members };
|
|
88
|
+
} catch {}
|
|
89
|
+
}
|
|
90
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return { runtime: null, members };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function nativeRequest(state, path, body = {}) {
|
|
97
|
+
if (!state?.native?.controlUrl) return null;
|
|
98
|
+
try {
|
|
99
|
+
const res = await fetch(`${state.native.controlUrl}${path}`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: { "Content-Type": "application/json" },
|
|
102
|
+
body: JSON.stringify(body),
|
|
103
|
+
});
|
|
104
|
+
return await res.json();
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export async function nativeGetStatus(state) {
|
|
111
|
+
if (!state?.native?.controlUrl) return null;
|
|
112
|
+
try {
|
|
113
|
+
const res = await fetch(`${state.native.controlUrl}/status`);
|
|
114
|
+
return await res.json();
|
|
115
|
+
} catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
detectMultiplexer,
|
|
3
|
-
hasWindowsTerminal,
|
|
4
|
-
hasWindowsTerminalSession,
|
|
5
|
-
sessionExists,
|
|
6
|
-
} from "../../session.mjs";
|
|
7
|
-
|
|
8
|
-
export function normalizeTeammateMode(mode = "auto") {
|
|
9
|
-
const raw = String(mode).toLowerCase();
|
|
10
|
-
if (raw === "inline" || raw === "native") return "in-process";
|
|
11
|
-
if (raw === "headless" || raw === "hl") return "headless";
|
|
12
|
-
if (raw === "psmux") return "headless";
|
|
13
|
-
if (raw === "in-process" || raw === "tmux" || raw === "wt") return raw;
|
|
14
|
-
if (raw === "windows-terminal" || raw === "windows_terminal") return "wt";
|
|
15
|
-
if (raw === "auto") {
|
|
16
|
-
if (process.env.TMUX) return "tmux";
|
|
17
|
-
return detectMultiplexer() === "psmux" ? "headless" : "in-process";
|
|
18
|
-
}
|
|
19
|
-
return "in-process";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function normalizeLayout(layout = "2x2") {
|
|
23
|
-
const raw = String(layout).toLowerCase();
|
|
24
|
-
if (raw === "2x2" || raw === "grid") return "2x2";
|
|
25
|
-
if (raw === "1xn" || raw === "1x3" || raw === "vertical" || raw === "columns") return "1xN";
|
|
26
|
-
if (raw === "nx1" || raw === "horizontal" || raw === "rows") return "Nx1";
|
|
27
|
-
return "2x2";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isNativeMode(state) {
|
|
31
|
-
return state?.teammateMode === "in-process" && !!state?.native?.controlUrl;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function isWtMode(state) {
|
|
35
|
-
return state?.teammateMode === "wt";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function isTeamAlive(state) {
|
|
39
|
-
if (!state) return false;
|
|
40
|
-
if (isNativeMode(state)) {
|
|
41
|
-
try {
|
|
42
|
-
process.kill(state.native.supervisorPid, 0);
|
|
43
|
-
return true;
|
|
44
|
-
} catch {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (isWtMode(state)) {
|
|
49
|
-
if (!hasWindowsTerminal()) return false;
|
|
50
|
-
if (hasWindowsTerminalSession()) return true;
|
|
51
|
-
return Array.isArray(state.members) && state.members.length > 0;
|
|
52
|
-
}
|
|
53
|
-
return sessionExists(state.sessionName);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function ensureTmuxOrExit() {
|
|
57
|
-
const mux = detectMultiplexer();
|
|
58
|
-
if (mux) return mux;
|
|
59
|
-
const error = new Error("tmux 미발견");
|
|
60
|
-
error.code = "TMUX_REQUIRED";
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
detectMultiplexer,
|
|
3
|
+
hasWindowsTerminal,
|
|
4
|
+
hasWindowsTerminalSession,
|
|
5
|
+
sessionExists,
|
|
6
|
+
} from "../../session.mjs";
|
|
7
|
+
|
|
8
|
+
export function normalizeTeammateMode(mode = "auto") {
|
|
9
|
+
const raw = String(mode).toLowerCase();
|
|
10
|
+
if (raw === "inline" || raw === "native") return "in-process";
|
|
11
|
+
if (raw === "headless" || raw === "hl") return "headless";
|
|
12
|
+
if (raw === "psmux") return "headless";
|
|
13
|
+
if (raw === "in-process" || raw === "tmux" || raw === "wt") return raw;
|
|
14
|
+
if (raw === "windows-terminal" || raw === "windows_terminal") return "wt";
|
|
15
|
+
if (raw === "auto") {
|
|
16
|
+
if (process.env.TMUX) return "tmux";
|
|
17
|
+
return detectMultiplexer() === "psmux" ? "headless" : "in-process";
|
|
18
|
+
}
|
|
19
|
+
return "in-process";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function normalizeLayout(layout = "2x2") {
|
|
23
|
+
const raw = String(layout).toLowerCase();
|
|
24
|
+
if (raw === "2x2" || raw === "grid") return "2x2";
|
|
25
|
+
if (raw === "1xn" || raw === "1x3" || raw === "vertical" || raw === "columns") return "1xN";
|
|
26
|
+
if (raw === "nx1" || raw === "horizontal" || raw === "rows") return "Nx1";
|
|
27
|
+
return "2x2";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isNativeMode(state) {
|
|
31
|
+
return state?.teammateMode === "in-process" && !!state?.native?.controlUrl;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isWtMode(state) {
|
|
35
|
+
return state?.teammateMode === "wt";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function isTeamAlive(state) {
|
|
39
|
+
if (!state) return false;
|
|
40
|
+
if (isNativeMode(state)) {
|
|
41
|
+
try {
|
|
42
|
+
process.kill(state.native.supervisorPid, 0);
|
|
43
|
+
return true;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (isWtMode(state)) {
|
|
49
|
+
if (!hasWindowsTerminal()) return false;
|
|
50
|
+
if (hasWindowsTerminalSession()) return true;
|
|
51
|
+
return Array.isArray(state.members) && state.members.length > 0;
|
|
52
|
+
}
|
|
53
|
+
return sessionExists(state.sessionName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function ensureTmuxOrExit() {
|
|
57
|
+
const mux = detectMultiplexer();
|
|
58
|
+
if (mux) return mux;
|
|
59
|
+
const error = new Error("tmux 미발견");
|
|
60
|
+
error.code = "TMUX_REQUIRED";
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { mkdirSync } from "node:fs";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
export const PKG_ROOT = fileURLToPath(new URL("../../../../", import.meta.url));
|
|
8
|
-
export const HUB_PID_DIR = join(homedir(), ".claude", "cache", "tfx-hub");
|
|
9
|
-
export const TEAM_PROFILE = (() => {
|
|
10
|
-
const raw = String(process.env.TFX_TEAM_PROFILE || "team").trim().toLowerCase();
|
|
11
|
-
return raw === "codex-team" ? "codex-team" : "team";
|
|
12
|
-
})();
|
|
13
|
-
|
|
14
|
-
export const SESSION_ID = process.env.CLAUDE_SESSION_ID || `s${Date.now()}`;
|
|
15
|
-
|
|
16
|
-
function getStatePath(sessionId) {
|
|
17
|
-
if (sessionId) return join(HUB_PID_DIR, `team-state-${sessionId}.json`);
|
|
18
|
-
return join(HUB_PID_DIR, TEAM_PROFILE === "codex-team" ? "team-state-codex-team.json" : "team-state.json");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function loadTeamState(sessionId) {
|
|
22
|
-
const resolvedId = sessionId || SESSION_ID;
|
|
23
|
-
const sessionPath = getStatePath(resolvedId);
|
|
24
|
-
try {
|
|
25
|
-
if (existsSync(sessionPath)) return JSON.parse(readFileSync(sessionPath, "utf8"));
|
|
26
|
-
} catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
// 세션별 파일 없으면 기존 team-state.json fallback
|
|
30
|
-
const legacyPath = getStatePath(null);
|
|
31
|
-
try {
|
|
32
|
-
if (existsSync(legacyPath)) return JSON.parse(readFileSync(legacyPath, "utf8"));
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function saveTeamState(state, sessionId) {
|
|
40
|
-
const path = getStatePath(sessionId || state.sessionId || SESSION_ID);
|
|
41
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
42
|
-
writeFileSync(path, JSON.stringify({ ...state, profile: TEAM_PROFILE }, null, 2) + "\n");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function clearTeamState(sessionId) {
|
|
46
|
-
const path = getStatePath(sessionId || SESSION_ID);
|
|
47
|
-
if (existsSync(path)) unlinkSync(path);
|
|
48
|
-
}
|
|
1
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { mkdirSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
export const PKG_ROOT = fileURLToPath(new URL("../../../../", import.meta.url));
|
|
8
|
+
export const HUB_PID_DIR = join(homedir(), ".claude", "cache", "tfx-hub");
|
|
9
|
+
export const TEAM_PROFILE = (() => {
|
|
10
|
+
const raw = String(process.env.TFX_TEAM_PROFILE || "team").trim().toLowerCase();
|
|
11
|
+
return raw === "codex-team" ? "codex-team" : "team";
|
|
12
|
+
})();
|
|
13
|
+
|
|
14
|
+
export const SESSION_ID = process.env.CLAUDE_SESSION_ID || `s${Date.now()}`;
|
|
15
|
+
|
|
16
|
+
function getStatePath(sessionId) {
|
|
17
|
+
if (sessionId) return join(HUB_PID_DIR, `team-state-${sessionId}.json`);
|
|
18
|
+
return join(HUB_PID_DIR, TEAM_PROFILE === "codex-team" ? "team-state-codex-team.json" : "team-state.json");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function loadTeamState(sessionId) {
|
|
22
|
+
const resolvedId = sessionId || SESSION_ID;
|
|
23
|
+
const sessionPath = getStatePath(resolvedId);
|
|
24
|
+
try {
|
|
25
|
+
if (existsSync(sessionPath)) return JSON.parse(readFileSync(sessionPath, "utf8"));
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
// 세션별 파일 없으면 기존 team-state.json fallback
|
|
30
|
+
const legacyPath = getStatePath(null);
|
|
31
|
+
try {
|
|
32
|
+
if (existsSync(legacyPath)) return JSON.parse(readFileSync(legacyPath, "utf8"));
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function saveTeamState(state, sessionId) {
|
|
40
|
+
const path = getStatePath(sessionId || state.sessionId || SESSION_ID);
|
|
41
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
42
|
+
writeFileSync(path, JSON.stringify({ ...state, profile: TEAM_PROFILE }, null, 2) + "\n");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function clearTeamState(sessionId) {
|
|
46
|
+
const path = getStatePath(sessionId || SESSION_ID);
|
|
47
|
+
if (existsSync(path)) unlinkSync(path);
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const DASHBOARD_ANCHORS = new Set([
|
|
2
|
+
"window",
|
|
3
|
+
"tab",
|
|
4
|
+
]);
|
|
5
|
+
|
|
6
|
+
export function normalizeDashboardAnchor(value) {
|
|
7
|
+
const normalized = String(value ?? "").trim().toLowerCase();
|
|
8
|
+
if (!normalized) return "window";
|
|
9
|
+
return DASHBOARD_ANCHORS.has(normalized) ? normalized : "window";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function parseDashboardAnchor(value) {
|
|
13
|
+
return normalizeDashboardAnchor(value);
|
|
14
|
+
}
|