pleumrouter 0.5.17 → 0.5.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pleumrouter",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "description": "Official PleumRouter terminal CLI — launch any coding agent against PleumRouter.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/balance.mjs CHANGED
@@ -10,5 +10,7 @@ export async function balance() {
10
10
  const data = await res.json();
11
11
  const plm = data.balance_krw;
12
12
  const usd = data.balance_usd != null ? ` / $${data.balance_usd.toFixed(4)}` : "";
13
- console.log(`잔액: ${plm.toLocaleString("ko-KR")} 크레딧${usd}`);
13
+ // 원장 눈금이 0.1이라 잔액은 소수 1자리 고정 표기(딱 떨어져도 ".0"을 남긴다).
14
+ const shown = plm.toLocaleString("ko-KR", { minimumFractionDigits: 1, maximumFractionDigits: 1 });
15
+ console.log(`잔액: ${shown} 크레딧${usd}`);
14
16
  }
package/src/login.mjs CHANGED
@@ -17,11 +17,17 @@ export function browserCommand(url, platform = process.platform) {
17
17
 
18
18
  function openBrowser(url) {
19
19
  const { command, args } = browserCommand(url);
20
- spawn(command, args, {
21
- stdio: "ignore",
22
- detached: true,
23
- shell: false,
24
- }).unref();
20
+ try {
21
+ const child = spawn(command, args, {
22
+ stdio: "ignore",
23
+ detached: true,
24
+ shell: false,
25
+ });
26
+ child.on("error", () => {});
27
+ child.unref();
28
+ } catch {
29
+ // Ignore synchronous spawn failure on headless environments
30
+ }
25
31
  }
26
32
 
27
33
  function saveTokens({ access_token, refresh_token, expires_in }) {
@@ -123,14 +129,21 @@ export async function loginDevice() {
123
129
  ` ${t("Log in at the URL above, then enter the code (within {min} min).", { min: expires_in / 60 })}\n`
124
130
  );
125
131
 
126
- const deadline = Date.now() + expires_in * 1000;
132
+ const expiresIn = Number(expires_in) || 600;
133
+ const pollInterval = Math.max(1, Number(interval) || 5);
134
+ const deadline = Date.now() + expiresIn * 1000;
127
135
  while (Date.now() < deadline) {
128
- await new Promise((r) => setTimeout(r, interval * 1000));
129
- const poll = await fetch(`${V1}/auth/device/token`, {
130
- method: "POST",
131
- headers: { "Content-Type": "application/json" },
132
- body: JSON.stringify({ device_code }),
133
- });
136
+ await new Promise((r) => setTimeout(r, pollInterval * 1000));
137
+ let poll;
138
+ try {
139
+ poll = await fetch(`${V1}/auth/device/token`, {
140
+ method: "POST",
141
+ headers: { "Content-Type": "application/json" },
142
+ body: JSON.stringify({ device_code }),
143
+ });
144
+ } catch {
145
+ continue; // Transient network error; retry on next poll tick
146
+ }
134
147
  if (poll.status === 202) continue; // authorization_pending
135
148
  if (!poll.ok) {
136
149
  const e = await poll.json().catch(() => ({}));
package/src/usage.mjs CHANGED
@@ -19,7 +19,9 @@ export function parseUsageArgs(rest = []) {
19
19
  return { by, days };
20
20
  }
21
21
 
22
- const fmtKrw = (n) => `${Math.round(n).toLocaleString("en-US")} 크레딧`;
22
+ // 원장 눈금 0.1 — Math.round로 자르면 소액 사용이 0으로 보인다.
23
+ const fmtKrw = (n) =>
24
+ `${Number(n).toLocaleString("en-US", { minimumFractionDigits: 1, maximumFractionDigits: 1 })} 크레딧`;
23
25
 
24
26
  // report 응답 → 표시 문자열(순수 함수 — fixture 테스트 대상).
25
27
  export function renderUsage(data, styler = style) {