relayax-cli 0.3.43 → 0.3.44
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/dist/commands/login.js
CHANGED
|
@@ -119,6 +119,46 @@ async function loginWithBrowser(json) {
|
|
|
119
119
|
}
|
|
120
120
|
return waitForToken(port);
|
|
121
121
|
}
|
|
122
|
+
async function loginWithDevice(json) {
|
|
123
|
+
const res = await fetch(`${config_js_1.API_URL}/api/auth/device/request`, { method: 'POST' });
|
|
124
|
+
if (!res.ok) {
|
|
125
|
+
throw new Error('Device code 발급에 실패했습니다');
|
|
126
|
+
}
|
|
127
|
+
const { device_code, user_code, verification_url, expires_in } = await res.json();
|
|
128
|
+
if (json) {
|
|
129
|
+
console.error(JSON.stringify({ status: 'waiting', verification_url, user_code, expires_in }));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.error(`\n아래 URL에서 코드를 입력하세요:\n`);
|
|
133
|
+
console.error(` ${verification_url}`);
|
|
134
|
+
console.error(`\n 코드: \x1b[1m${user_code}\x1b[0m\n`);
|
|
135
|
+
}
|
|
136
|
+
openBrowser(`${verification_url}?user_code=${user_code}`);
|
|
137
|
+
const deadline = Date.now() + expires_in * 1000;
|
|
138
|
+
while (Date.now() < deadline) {
|
|
139
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
140
|
+
const pollRes = await fetch(`${config_js_1.API_URL}/api/auth/device/poll`, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: { 'Content-Type': 'application/json' },
|
|
143
|
+
body: JSON.stringify({ device_code }),
|
|
144
|
+
});
|
|
145
|
+
if (!pollRes.ok)
|
|
146
|
+
continue;
|
|
147
|
+
const data = await pollRes.json();
|
|
148
|
+
if (data.status === 'approved' && data.token) {
|
|
149
|
+
return {
|
|
150
|
+
token: data.token,
|
|
151
|
+
refresh_token: data.refresh_token,
|
|
152
|
+
expires_at: data.expires_at ? Number(data.expires_at) : undefined,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (data.status === 'expired') {
|
|
156
|
+
throw new Error('코드가 만료되었습니다. 다시 시도하세요.');
|
|
157
|
+
}
|
|
158
|
+
// pending — continue polling
|
|
159
|
+
}
|
|
160
|
+
throw new Error('로그인 시간이 초과되었습니다 (5분)');
|
|
161
|
+
}
|
|
122
162
|
/**
|
|
123
163
|
* 대화형 로그인 플로우 실행 (auto-login에서 호출).
|
|
124
164
|
* 브라우저에서 로그인 페이지를 열고 토큰을 받아 저장.
|
|
@@ -139,6 +179,7 @@ function registerLogin(program) {
|
|
|
139
179
|
.command('login')
|
|
140
180
|
.description('RelayAX 계정에 로그인합니다')
|
|
141
181
|
.option('--token <token>', '직접 토큰 입력 (브라우저 없이)')
|
|
182
|
+
.option('--device', 'Device code 방식으로 로그인 (샌드박스/원격 환경용)')
|
|
142
183
|
.action(async (opts) => {
|
|
143
184
|
const json = program.opts().json ?? false;
|
|
144
185
|
(0, config_js_1.ensureGlobalRelayDir)();
|
|
@@ -146,8 +187,9 @@ function registerLogin(program) {
|
|
|
146
187
|
let refreshToken;
|
|
147
188
|
let expiresAt;
|
|
148
189
|
if (!accessToken) {
|
|
190
|
+
const loginFn = opts.device ? loginWithDevice : loginWithBrowser;
|
|
149
191
|
try {
|
|
150
|
-
const loginResult = await
|
|
192
|
+
const loginResult = await loginFn(json);
|
|
151
193
|
accessToken = loginResult.token;
|
|
152
194
|
refreshToken = loginResult.refresh_token;
|
|
153
195
|
expiresAt = loginResult.expires_at;
|
|
@@ -155,10 +197,13 @@ function registerLogin(program) {
|
|
|
155
197
|
catch (err) {
|
|
156
198
|
const msg = err instanceof Error ? err.message : '로그인 실패';
|
|
157
199
|
if (json) {
|
|
158
|
-
console.error(JSON.stringify({ error: 'LOGIN_FAILED', message: msg, fix: '
|
|
200
|
+
console.error(JSON.stringify({ error: 'LOGIN_FAILED', message: msg, fix: opts.device ? '다시 시도하세요.' : 'relay login --device를 시도하세요.' }));
|
|
159
201
|
}
|
|
160
202
|
else {
|
|
161
203
|
console.error(`\x1b[31m오류: ${msg}\x1b[0m`);
|
|
204
|
+
if (!opts.device) {
|
|
205
|
+
console.error(`\n\x1b[33m팁: 브라우저 콜백이 안 되는 환경이라면 relay login --device를 시도하세요.\x1b[0m`);
|
|
206
|
+
}
|
|
162
207
|
}
|
|
163
208
|
process.exit(1);
|
|
164
209
|
}
|
package/dist/lib/guide.js
CHANGED
|
@@ -79,8 +79,11 @@ ${commands.map((cmd) => `- \`/${cmd.name}\`: ${cmd.description}`).join('\n')}
|
|
|
79
79
|
|
|
80
80
|
> ${config.description}
|
|
81
81
|
|
|
82
|
-
이 가이드는
|
|
83
|
-
|
|
82
|
+
이 가이드는 Relay 에이전트를 설치하는 절차입니다.
|
|
83
|
+
각 Step의 명령어를 순서대로 실행하세요. 요약하지 말고 바로 Step 1부터 시작하세요.
|
|
84
|
+
|
|
85
|
+
터미널(bash)을 실행할 수 없는 환경이라면, 아래 도구에서 이 URL을 열고 실행하세요:
|
|
86
|
+
Claude Code · Claude Cowork · Codex · Cursor · Antigravity
|
|
84
87
|
|
|
85
88
|
${setupSection}
|
|
86
89
|
|
|
@@ -17,3 +17,10 @@ mkdir -p ~/.npm-global && npm config set prefix '~/.npm-global'
|
|
|
17
17
|
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc && source ~/.zshrc
|
|
18
18
|
npm install -g relayax-cli
|
|
19
19
|
```
|
|
20
|
+
|
|
21
|
+
이미 설치되어 있다면 최신 버전으로 업데이트하고 init을 재실행합니다:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm update -g relayax-cli
|
|
25
|
+
relay init
|
|
26
|
+
```
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
## Step 2. 로그인
|
|
2
2
|
|
|
3
|
+
먼저 `relay whoami`로 로그인 상태를 확인합니다. 이미 로그인되어 있으면 이 단계를 건너뛰세요.
|
|
4
|
+
|
|
5
|
+
로그인이 필요하면 아래 두 방법 중 하나를 사용하세요.
|
|
6
|
+
|
|
7
|
+
### 방법 A: 브라우저 콜백 (로컬 터미널)
|
|
8
|
+
|
|
9
|
+
로컬 머신에서 직접 터미널을 사용하는 경우 이 방법을 사용합니다.
|
|
10
|
+
`relay login`은 로컬 콜백 서버를 띄우고 브라우저 로그인 완료를 기다립니다.
|
|
11
|
+
반드시 포그라운드에서 실행하고, timeout을 300초(5분) 이상으로 설정하세요.
|
|
12
|
+
|
|
3
13
|
```bash
|
|
4
14
|
relay login
|
|
5
15
|
```
|
|
6
16
|
|
|
7
|
-
브라우저가 열리면 GitHub 또는 카카오 계정으로
|
|
17
|
+
- 브라우저가 자동으로 열리면 GitHub 또는 카카오 계정으로 로그인합니다.
|
|
18
|
+
- 브라우저가 열리지 않으면 CLI 출력에서 로그인 URL을 찾아 별도 명령어로 엽니다: `open <URL>` (macOS) / `xdg-open <URL>` (Linux)
|
|
19
|
+
|
|
20
|
+
"✓ 로그인 완료"가 출력되면 다음 단계로 진행합니다.
|
|
21
|
+
|
|
22
|
+
### 방법 B: Device Code (샌드박스/원격 환경)
|
|
23
|
+
|
|
24
|
+
Cowork, 원격 서버 등 브라우저 콜백이 localhost에 도달할 수 없는 환경에서는 이 방법을 사용합니다.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
relay login --device
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
- 화면에 URL과 8자리 코드가 표시됩니다.
|
|
31
|
+
- 브라우저가 자동으로 열립니다. 열리지 않으면 표시된 URL을 별도 명령어로 엽니다: `open <URL>` (macOS) / `xdg-open <URL>` (Linux)
|
|
32
|
+
- 브라우저에서 코드를 입력하고 로그인을 승인합니다.
|
|
33
|
+
- CLI가 자동으로 승인을 감지하고 "✓ 로그인 완료"를 출력합니다.
|
|
34
|
+
|
|
35
|
+
`relay whoami`로 로그인 성공을 확인한 후 다음 단계로 진행합니다.
|