@sejuneoh/aitop 0.33.0 → 0.33.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/README.md CHANGED
@@ -109,7 +109,7 @@ aitop --report sessions --since 7d --json
109
109
  Off by default and only on the live screen. Sessions already waiting (or already over 90% context) when aitop starts are not reported.
110
110
 
111
111
  ```
112
- aitop --notify desktop notification when a session starts waiting (notify-send on Linux/WSL, osascript on macOS)
112
+ aitop --notify desktop notification when a session starts waiting (notify-send on Linux, Windows notification on WSL, osascript on macOS)
113
113
  aitop --notify=waiting,done,context pick the kinds; plain --notify uses the config file kinds, or waiting only when none are set
114
114
  aitop --on-waiting 'my-hook.sh' run a command with /bin/sh -c for the same events (10 second limit, runs as you)
115
115
  ```
@@ -120,6 +120,8 @@ aitop --on-waiting 'my-hook.sh' run a command with /bin/sh -c for the same
120
120
 
121
121
  The hook keeps its name: it gets `AITOP_EVENT` (`waiting`, `done` or `context`) plus `AITOP_TOOL`, `AITOP_PROJECT`, `AITOP_SESSION_ID`, `AITOP_CWD` and `AITOP_WAITING_FOR` in its environment. Config file: `"notify": true` or `"notify": ["waiting", "done", "context"]`, `"onWaiting": "..."` (file must be `chmod 600`), `"doneMinutes": 5`. Plain `--notify` keeps the kinds from the config `notify` list (waiting only when there is none). `--no-notify` turns off only the desktop notification: the hook still follows those kinds. `--bell` stays waiting only.
122
122
 
123
+ On WSL, aitop shows a Windows notification through `powershell.exe` (as Windows PowerShell, no setup needed) and falls back to notify-send when `powershell.exe` is not on the PATH. notify-send needs a D-Bus session bus: when `DBUS_SESSION_BUS_ADDRESS` is unset or its socket file is missing, notifications cannot show and `--doctor` marks the line with `!`. A missing tool or a failed notification is skipped quietly.
124
+
123
125
  The notification body shows the session's own name when it has one (Claude Code `/rename`, or a name given by a peer session; Codex `thread_name`), otherwise the project. Desktop notifications can appear on the lock screen, so the name is visible there too.
124
126
 
125
127
  ### tmux status line
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sejuneoh/aitop",
3
- "version": "0.33.0",
3
+ "version": "0.33.2",
4
4
  "description": "터미널에서 Claude Code · Codex · Antigravity · Gemini 세션과 토큰을 실시간으로 보는 읽기 전용 모니터",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/doctor.mjs CHANGED
@@ -10,7 +10,7 @@ import { loadSqlite, openReadOnly } from './sqlite.mjs';
10
10
  import { fmtAgo, pad, stripControl } from './text.mjs';
11
11
  import { BRAND } from './brand.mjs';
12
12
  import { tildeIn } from './paths.mjs';
13
- import { findNotifier, isWsl } from './notify.mjs';
13
+ import { busProblem, findNotifier, isWsl } from './notify.mjs';
14
14
  import { getLang, t as tr } from './i18n.mjs';
15
15
  import { candidateDirs, claudeDirs, codexHomes } from './sources/dirs.mjs';
16
16
 
@@ -213,17 +213,32 @@ export function checkTools({ home = HOME } = {}) {
213
213
  r.hint = hintOf(r, 'ko');
214
214
  tools[r.tool] = r;
215
215
  }
216
- const n = findNotifier();
217
- return { platform: platform(), processes: canListProcesses(), tools, notifier: n ? { kind: n.kind, path: tilde(n.path) } : null };
216
+ return { platform: platform(), processes: canListProcesses(), tools, notifier: notifierCheck() };
218
217
  }
219
218
 
220
- // --notify 에 쓸 데스크톱 알림 도구.
221
- export function notifierText(n, plat = platform(), lang = getLang()) {
219
+ // 알림 도구와, notify-send 면 D-Bus 세션 버스를 찾을 수 있는지 (#250). 알림을 실제로 보내 보지는 않는다.
220
+ // bus: 문제가 있을 때만 { reason, path? }. 테스트에서 platform·env·wsl·exists 를 바꿔 끼운다.
221
+ export function notifierCheck({ platform: plat = platform(), env = process.env, wsl = plat === 'linux' && isWsl(env), exists } = {}) {
222
+ const n = findNotifier({ platform: plat, env, wsl });
223
+ if (!n) return null;
224
+ const bus = n.kind === 'notify-send' ? busProblem(env, exists) : null;
225
+ return { kind: n.kind, path: tilde(n.path), ...(bus ? { bus: bus.path ? { ...bus, path: tilde(bus.path) } : bus } : {}) };
226
+ }
227
+
228
+ // --notify 에 쓸 데스크톱 알림 도구. 알림이 뜨지 않을 것이 확실하면 ! 와 안내 줄(→)을 붙인다.
229
+ export function notifierText(n, plat = platform(), lang = getLang(), wsl = plat === 'linux' && isWsl()) {
222
230
  const o = { lang };
231
+ const hint = (k) => ` → ${tr(k, null, o)}`;
232
+ if (n?.bus) {
233
+ const why = n.bus.reason === 'socket' ? tr('doctor.busSocket', { path: n.bus.path }, o) : tr('doctor.busMissing', null, o);
234
+ const out = [tr('doctor.busBad', { kind: n.kind, path: n.path, why }, o), hint('doctor.busHint')];
235
+ if (wsl) out.push(hint('doctor.wslHint'));
236
+ return out.join('\n');
237
+ }
223
238
  if (n) return tr('doctor.notifier', { kind: n.kind, path: n.path }, o);
239
+ if (wsl) return [tr('doctor.noNotifierWsl', null, o), hint('doctor.wslHint')].join('\n');
224
240
  const want = plat === 'darwin' ? 'osascript' : 'notify-send';
225
- const wsl = plat === 'linux' && isWsl() ? tr('doctor.wsl', null, o) : '';
226
- return tr('doctor.noNotifier', { want, wsl }, o);
241
+ return tr('doctor.noNotifier', { want }, o);
227
242
  }
228
243
 
229
244
  // JSON 용: 시각은 ISO 문자열로.
package/src/i18n.mjs CHANGED
@@ -79,7 +79,7 @@ const HELP_KO = `{logo} aitop - 터미널에서 Claude Code · Codex · Antigrav
79
79
  --plan 월 구독료를 주면 기간 몫의 몇 배인지 보인다. --md 는 붙여 넣을 Markdown. 첫 지시는 --show-prompts 일 때만
80
80
  aitop --doctor Claude · Codex · Antigravity · Gemini 기록과 실행 중인 프로세스, 설정 파일을 점검한다 (--json 과 함께 쓸 수 있다)
81
81
  aitop --bell 응답 대기 세션이 새로 생기면 터미널 벨을 울린다
82
- aitop --notify 응답 대기 세션이 새로 생기면 데스크톱 알림을 띄운다 (notify-send · osascript, 없으면 건너뜀)
82
+ aitop --notify 응답 대기 세션이 새로 생기면 데스크톱 알림을 띄운다 (Linux notify-send · macOS osascript · WSL 은 powershell.exe 로 Windows 알림, 없으면 건너뜀)
83
83
  aitop --notify=waiting,done,context 알릴 종류를 고른다 (--notify 만 주면 설정 파일 notify 배열, 없으면 waiting). done: 3분(설정 파일 doneMinutes, 응답 대기 시간 빼고) 넘게 작업하던 세션이 다음 지시를
84
84
  기다리면 한 번. context: 컨텍스트가 90% 를 넘으면 한 번 (85% 아래로 내려가면 다시)
85
85
  aitop --on-waiting <명령> 알릴 일이 생기면 /bin/sh -c 로 명령을 실행한다 (내 권한으로 실행, 10초 제한). 종류는 --notify 를 따른다 (--no-notify 여도)
@@ -138,7 +138,7 @@ const HELP_EN = `{logo} aitop - watch Claude Code, Codex, Antigravity and Gemini
138
138
  First prompts are shown only with --show-prompts
139
139
  aitop --doctor check Claude, Codex, Antigravity and Gemini logs, running processes and the config file (works with --json)
140
140
  aitop --bell ring the terminal bell when a session starts waiting for you
141
- aitop --notify show a desktop notification when a session starts waiting (notify-send or osascript, skipped if missing)
141
+ aitop --notify show a desktop notification when a session starts waiting (notify-send on Linux, osascript on macOS, a Windows toast via powershell.exe on WSL; skipped if missing)
142
142
  aitop --notify=waiting,done,context pick what to notify about (plain --notify: the config notify list, else waiting). done: once when a session that worked for
143
143
  over 3 minutes (config doneMinutes, approval waits not counted) waits for its next instruction. context: once when context passes 90% (again after it drops below 85%)
144
144
  aitop --on-waiting <cmd> run a command with /bin/sh -c when there is something to notify (runs as you, 10 second limit). Follows the --notify kinds (even with --no-notify)
@@ -335,8 +335,13 @@ export const STRINGS = {
335
335
  'doctor.hint.gemini': '프로세스만 감지합니다 (세션·토큰은 아직 지원하지 않음)',
336
336
  'doctor.hint.agyNode': 'Node {node} 에서는 기록을 읽기 전용으로 열 수 없어 프로세스만 감지합니다 (Node 22.15 이상 필요)',
337
337
  'doctor.notifier': '✓ 알림 {kind} ({path}) · --notify 로 켬 (끝남·context 경고는 --notify=waiting,done,context)',
338
- 'doctor.noNotifier': '○ 알림 {want} 없음 · --notify 를 켜도 알림을 건너뜀{wsl}',
339
- 'doctor.wsl': ' (WSL 은 notify-send 만 쓴다)',
338
+ 'doctor.noNotifier': '○ 알림 {want} 없음 · --notify 를 켜도 알림을 건너뜀',
339
+ 'doctor.noNotifierWsl': '! 알림 powershell.exe·notify-send 없음 · --notify 를 켜도 알림을 건너뜀',
340
+ 'doctor.wslHint': 'WSL 은 powershell.exe 로 Windows 알림을 띄운다. Windows PATH 를 넣었는지(/etc/wsl.conf 의 appendWindowsPath) 확인한다',
341
+ 'doctor.busBad': '! 알림 {kind} ({path}) · D-Bus 세션 버스가 없어 알림이 뜨지 않음 ({why})',
342
+ 'doctor.busMissing': 'DBUS_SESSION_BUS_ADDRESS 없음',
343
+ 'doctor.busSocket': '{path} 소켓 없음',
344
+ 'doctor.busHint': '데스크톱 세션 안에서 실행하거나 사용자 D-Bus(systemctl --user, dbus-launch)를 켠다. 대신 --on-waiting 으로 다른 알림 명령을 부를 수 있다',
340
345
  'doctor.config': '{mark} 설정 {state}{path}',
341
346
  'doctor.configExists': '있음',
342
347
  'doctor.configMissing': '없음 (기본값)',
@@ -751,8 +756,13 @@ export const STRINGS = {
751
756
  'doctor.hint.gemini': 'detects processes only (sessions and tokens not supported yet)',
752
757
  'doctor.hint.agyNode': 'Node {node} cannot open the logs read-only, so only processes are detected (needs Node 22.15 or later)',
753
758
  'doctor.notifier': '✓ notify {kind} ({path}) · turn on with --notify (done and context alerts: --notify=waiting,done,context)',
754
- 'doctor.noNotifier': '○ notify {want} not found · --notify will skip notifications{wsl}',
755
- 'doctor.wsl': ' (WSL uses notify-send only)',
759
+ 'doctor.noNotifier': '○ notify {want} not found · --notify will skip notifications',
760
+ 'doctor.noNotifierWsl': '! notify powershell.exe and notify-send not found · --notify will skip notifications',
761
+ 'doctor.wslHint': 'WSL shows Windows notifications through powershell.exe. Check that the Windows PATH is added (appendWindowsPath in /etc/wsl.conf)',
762
+ 'doctor.busBad': '! notify {kind} ({path}) · no D-Bus session bus, notifications will not show ({why})',
763
+ 'doctor.busMissing': 'DBUS_SESSION_BUS_ADDRESS not set',
764
+ 'doctor.busSocket': 'no socket at {path}',
765
+ 'doctor.busHint': 'run inside a desktop session or start a user D-Bus (systemctl --user, dbus-launch). Or call another notifier with --on-waiting',
756
766
  'doctor.config': '{mark} config {state}{path}',
757
767
  'doctor.configExists': 'found',
758
768
  'doctor.configMissing': 'not found',
package/src/notify.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // 알림: --notify[=종류] (데스크톱 알림), --on-waiting <명령> (사용자 명령 실행). 종류는 waiting(기본)·done·context.
2
2
  // 세션 정보는 명령 문자열에 넣지 않는다. 알림 도구에는 인자로, 사용자 명령에는 AITOP_* 환경변수로만 넘긴다.
3
3
  import { spawn } from 'node:child_process';
4
- import { accessSync, constants, readFileSync } from 'node:fs';
5
- import { join, delimiter } from 'node:path';
4
+ import { accessSync, constants, existsSync, readFileSync } from 'node:fs';
5
+ import { join, delimiter, posix } from 'node:path';
6
6
  import { mask, stripControl } from './text.mjs';
7
7
  import { getLang, phaseText, t } from './i18n.mjs';
8
8
 
@@ -95,7 +95,7 @@ export function which(name, envPath = process.env.PATH ?? '') {
95
95
  return null;
96
96
  }
97
97
 
98
- // WSL 인지. --doctor 의 알림 안내에 쓴다. readVersion 은 테스트에서 /proc/version 대신 넣는다.
98
+ // WSL 인지. 알림 수단 고르기와 --doctor 의 알림 안내에 쓴다. readVersion 은 테스트에서 /proc/version 대신 넣는다.
99
99
  export function isWsl(env = process.env, readVersion = () => readFileSync('/proc/version', 'utf8')) {
100
100
  if (env.WSL_DISTRO_NAME || env.WSL_INTEROP) return true;
101
101
  try {
@@ -106,24 +106,85 @@ export function isWsl(env = process.env, readVersion = () => readFileSync('/proc
106
106
  }
107
107
 
108
108
  // 쓸 수 있는 데스크톱 알림 도구. 없으면 null (조용히 건너뛴다).
109
- // Linux·WSL 은 notify-send 만 쓴다. WSL 에서 없으면 powershell 로 대신하지 않는다.
110
- export function findNotifier({ platform = process.platform, env = process.env } = {}) {
109
+ // WSL 은 powershell.exe 로 Windows 토스트를 먼저 띄운다 (WSL 에는 D-Bus 세션 버스가 없는 일이 흔하다, #250).
110
+ // powershell.exe 가 없으면 notify-send 를 쓴다. 일반 Linux 는 notify-send 만 쓴다.
111
+ // wsl 은 테스트에서 바꿔 끼운다.
112
+ export function findNotifier({ platform = process.platform, env = process.env, wsl = platform === 'linux' && isWsl(env) } = {}) {
111
113
  if (platform === 'darwin') {
112
114
  const path = which('osascript', env.PATH);
113
115
  return path ? { kind: 'osascript', path } : null;
114
116
  }
115
117
  if (platform === 'linux') {
118
+ if (wsl) {
119
+ const ps = which('powershell.exe', env.PATH);
120
+ if (ps) return { kind: 'powershell', path: ps };
121
+ }
116
122
  const path = which('notify-send', env.PATH);
117
123
  return path ? { kind: 'notify-send', path } : null;
118
124
  }
119
125
  return null;
120
126
  }
121
127
 
128
+ // notify-send 가 기대는 D-Bus 세션 버스를 찾을 수 있는지. 알림을 실제로 보내 보지는 않는다 (--doctor 가 알림을 띄우면 안 된다).
129
+ // 문제가 없거나 확인할 수 없으면 null, 주소가 없으면 { reason: 'missing' }, unix:path= 소켓이 모두 없으면 { reason: 'socket', path }.
130
+ // 주소가 없을 때 GLib 처럼 $XDG_RUNTIME_DIR/bus 를 먼저 본다. abstract 소켓·tcp 등은 파일로 확인할 수 없으니 문제로 보지 않는다. 버스 경로는 늘 POSIX 경로라 posix.join 으로 잇는다 (Windows 에서 돌려도 같은 결과).
131
+ export function busProblem(env = process.env, exists = existsSync) {
132
+ const addr = env.DBUS_SESSION_BUS_ADDRESS;
133
+ if (!addr) {
134
+ if (env.XDG_RUNTIME_DIR && exists(posix.join(env.XDG_RUNTIME_DIR, 'bus'))) return null;
135
+ return { reason: 'missing' };
136
+ }
137
+ let firstPath = null;
138
+ for (const entry of addr.split(';')) {
139
+ const m = /^unix:(.*)$/.exec(entry.trim());
140
+ if (!m) return null;
141
+ const keys = Object.fromEntries(m[1].split(',').map((kv) => [kv.slice(0, kv.indexOf('=')), kv.slice(kv.indexOf('=') + 1)]));
142
+ if (keys.path == null) return null;
143
+ let path;
144
+ try {
145
+ path = decodeURIComponent(keys.path);
146
+ } catch {
147
+ path = keys.path;
148
+ }
149
+ if (exists(path)) return null;
150
+ firstPath ??= path;
151
+ }
152
+ return firstPath ? { reason: 'socket', path: firstPath } : null;
153
+ }
154
+
155
+ // Windows PowerShell 의 AUMID. 시작 메뉴에 등록되어 있어 따로 등록하지 않아도 토스트가 뜬다 (Get-StartApps 로 확인).
156
+ export const PS_APP_ID = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe';
157
+ const TOAST_MAX = 250;
158
+
159
+ // Windows 토스트를 띄우는 PowerShell 스크립트. Windows 네이티브(#197)에서도 그대로 쓸 수 있게 따로 둔다.
160
+ // 제목·본문은 UTF-8 base64 로만 스크립트에 들어가고(글자는 A-Z a-z 0-9 + / = 뿐), 스크립트 안에서 풀어
161
+ // XML 글 노드(CreateTextNode)로 넣는다. 그래서 따옴표·$()·XML 특수문자가 명령이나 XML 구조를 바꾸지 못한다.
162
+ export function toastScript(title, body, appId = PS_APP_ID) {
163
+ const b64 = (v) => Buffer.from(String(v).slice(0, TOAST_MAX), 'utf8').toString('base64');
164
+ const id = b64(appId);
165
+ return [
166
+ "$ErrorActionPreference = 'Stop'",
167
+ '$d = { param($s) [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($s)) }',
168
+ '[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null',
169
+ '$x = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)',
170
+ "$n = $x.GetElementsByTagName('text')",
171
+ `$n.Item(0).AppendChild($x.CreateTextNode((& $d '${b64(title)}'))) > $null`,
172
+ `$n.Item(1).AppendChild($x.CreateTextNode((& $d '${b64(body)}'))) > $null`,
173
+ `[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier((& $d '${id}')).Show([Windows.UI.Notifications.ToastNotification]::new($x))`,
174
+ ].join('\n');
175
+ }
176
+
177
+ // powershell.exe -EncodedCommand 의 값: 스크립트를 UTF-16LE 로 바꿔 base64.
178
+ export const encodePowerShell = (script) => Buffer.from(script, 'utf16le').toString('base64');
179
+
122
180
  // 알림 도구 실행 인자. 제목·본문은 인자로만 넘긴다 (셸·AppleScript 문자열에 넣지 않는다).
123
181
  export function notifierCommand(notifier, title, body) {
124
182
  if (notifier.kind === 'osascript') {
125
183
  return [notifier.path, ['-e', 'on run argv', '-e', 'display notification (item 2 of argv) with title (item 1 of argv)', '-e', 'end run', title, body]];
126
184
  }
185
+ if (notifier.kind === 'powershell') {
186
+ return [notifier.path, ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', encodePowerShell(toastScript(title, body))]];
187
+ }
127
188
  // notify-send 는 본문을 마크업으로 읽으므로 <, >, & 를 바꿔 넣는다.
128
189
  return [notifier.path, ['--app-name=aitop', '--', escapeMarkup(title), escapeMarkup(body)]];
129
190
  }
@@ -176,6 +237,7 @@ export function notifyText(sessions, lang = getLang(), kind = 'waiting') {
176
237
  // 실행 중에 새 일이 오면 하나만 대기열에 두고(가장 최근 것으로 덮어씀), 끝나면 그것을 실행한다.
177
238
  // 출력은 버리고, timeoutMs 가 지나면 프로세스 그룹째(셸과 그 자식) SIGKILL 한다.
178
239
  // 자식은 'exit' 를 받아 거두므로 좀비가 남지 않는다. UI 루프는 기다리지 않는다.
240
+ // WSL 의 powershell.exe 는 Windows 쪽 프로세스지만, Linux 쪽 중계 프로세스를 SIGKILL 하면 Windows 프로세스도 함께 끝난다 (#250 에서 확인).
179
241
  function killGroup(c, sig) {
180
242
  try {
181
243
  process.kill(-c.pid, sig);
package/src/pricing.mjs CHANGED
@@ -1,28 +1,40 @@
1
1
  // Claude API 정가 기준 환산 비용 (USD / 100만 토큰). 구독 요금제 사용분도 "API 로 썼다면" 기준으로 계산한다.
2
- // 출처: Anthropic 모델 가격표(2026-10). 캐시 읽기는 입력가의 0.1배, 캐시 쓰기는 5분 1.25배·1시간 2배.
2
+ // 출처: Anthropic 공식 가격표 https://platform.claude.com/docs/en/about-claude/pricing (2026-11-18 확인).
3
+ // 캐시 읽기는 기본 입력가의 0.1배이고 표에 cacheRead 가 있는 모델만 다르다 (Fable·Mythos 5.1/5.2 는 0.025배, Opus·Sonnet 5.5 는 0.05배).
4
+ // 캐시 쓰기는 5분 1.25배·1시간 2배. Haiku 5.5 의 10만 토큰 초과 요청 단가(5배)는 반영하지 않는다:
5
+ // 보관 벡터(monthly.mjs)에는 요청별 크기가 남지 않아서, 모두 기본 단가로 계산한다.
3
6
  import { createHash } from 'node:crypto';
4
7
 
5
8
  const PRICES = {
9
+ 'claude-fable-5-2': { input: 8, output: 40, cacheRead: 0.2, fast: 2 },
10
+ 'claude-mythos-5-2': { input: 8, output: 40, cacheRead: 0.2, fast: 2 },
6
11
  'claude-fable-5-1': { input: 10, output: 50, cacheRead: 0.25 },
7
12
  'claude-mythos-5-1': { input: 10, output: 50, cacheRead: 0.25 },
8
13
  'claude-fable-5': { input: 10, output: 50 },
14
+ 'claude-mythos-5': { input: 10, output: 50 },
9
15
  'claude-opus-5-5': { input: 4, output: 20, cacheRead: 0.2, fast: 2 },
10
16
  'claude-opus-5': { input: 5, output: 25, fast: 2 },
11
17
  'claude-opus-4-8': { input: 5, output: 25, fast: 2 },
12
18
  'claude-opus-4-7': { input: 5, output: 25 },
13
19
  'claude-opus-4-6': { input: 5, output: 25 },
14
- 'claude-sonnet-5-5': { input: 2, output: 10, cacheRead: 0.2 },
20
+ 'claude-opus-4-5': { input: 5, output: 25 },
21
+ 'claude-opus-4-1': { input: 15, output: 75 },
22
+ 'claude-opus-4': { input: 15, output: 75 },
23
+ 'claude-sonnet-5-5': { input: 2, output: 10, cacheRead: 0.1 },
15
24
  'claude-sonnet-5': { input: 2, output: 10 },
16
25
  'claude-sonnet-4-6': { input: 3, output: 15 },
26
+ 'claude-sonnet-4-5': { input: 3, output: 15 },
27
+ 'claude-sonnet-4': { input: 3, output: 15 },
17
28
  'claude-haiku-5-5': { input: 0.1, output: 0.5 },
18
29
  'claude-haiku-4-5': { input: 1, output: 5 },
19
30
  };
20
31
 
21
32
  // Gemini API 정가 (USD / 100만 토큰, 유료 등급 standard). Antigravity CLI(agy) 사용분을 "API 로 썼다면" 기준으로 계산한다.
22
- // 출처: Google 공식 가격표 https://aistudio.google.com/docs/pricing (2026-11-06 확인). 긴 컨텍스트 구간은 따로 없다.
33
+ // 출처: Google 공식 가격표 https://aistudio.google.com/docs/pricing (2026-11-18 확인). 긴 컨텍스트 구간은 따로 없다.
23
34
  // 출력에는 생각 토큰이 들어 있고, cacheRead 는 context caching 가격이다. 가격이 바뀌는 모델은 날짜순 목록이며,
24
35
  // from 은 그 가격이 시작되는 날(UTC 0시)이다.
25
36
  const GEMINI_PRICES = {
37
+ 'gemini-4-hydrogen': [{ input: 1.5, output: 7.5, cacheRead: 0.075 }],
26
38
  'gemini-4-argon': [
27
39
  { input: 2, output: 10, cacheRead: 0.1 },
28
40
  { from: '2026-12-01', input: 4, output: 20, cacheRead: 0.2 },
@@ -42,21 +54,29 @@ const GEMINI_PRICES = {
42
54
  // 가격표의 지문(8자리). 표의 값이 하나라도 바뀌면 지문도 바뀐다.
43
55
  export const priceTag = (tables) => createHash('sha1').update(JSON.stringify(tables)).digest('hex').slice(0, 8);
44
56
 
45
- // 모델별 컨텍스트 창 크기(토큰). 출처: Anthropic 모델 표(2026-10). 표에 없는 모델은 contextWindow 가 추측한다.
57
+ // 모델별 컨텍스트 창 크기(토큰). 출처: Anthropic 모델 표 https://platform.claude.com/docs/en/about-claude/models/overview (2026-11-18 확인). 표에 없는 모델은 contextWindow 가 추측한다.
46
58
  const WINDOWS = {
47
59
  // Gemini 계열의 입력 한도(1,048,576 토큰). Antigravity 의 내부 모델 이름(gemini-4-argon 등)도 같다고 본다.
48
60
  'gemini-': 1_048_576,
61
+ 'claude-fable-5-2': 1_000_000,
62
+ 'claude-mythos-5-2': 1_000_000,
49
63
  'claude-fable-5-1': 1_000_000,
50
64
  'claude-mythos-5-1': 1_000_000,
51
65
  'claude-fable-5': 1_000_000,
66
+ 'claude-mythos-5': 1_000_000,
52
67
  'claude-opus-5-5': 1_000_000,
53
68
  'claude-opus-5': 1_000_000,
54
69
  'claude-opus-4-8': 1_000_000,
55
70
  'claude-opus-4-7': 1_000_000,
56
71
  'claude-opus-4-6': 1_000_000,
72
+ 'claude-opus-4-5': 200_000,
73
+ 'claude-opus-4-1': 200_000,
74
+ 'claude-opus-4': 200_000,
57
75
  'claude-sonnet-5-5': 1_000_000,
58
76
  'claude-sonnet-5': 1_000_000,
59
77
  'claude-sonnet-4-6': 1_000_000,
78
+ 'claude-sonnet-4-5': 200_000,
79
+ 'claude-sonnet-4': 200_000,
60
80
  'claude-haiku-5-5': 1_000_000,
61
81
  'claude-haiku-4-5': 200_000,
62
82
  };
@@ -71,8 +91,11 @@ function lookup(table, model) {
71
91
  }
72
92
 
73
93
  // 모르는 모델은 사용량으로 추측한다: 200k 를 넘었으면 1M 창, 아니면 200k 창.
94
+ // 표에 있어도 사용량이 표 값을 넘으면 추측 값을 쓴다: Sonnet 4/4.5 는 1M 베타로 200K 를 넘을 수 있는데, 기록의 모델 이름으로는 구분되지 않는다.
74
95
  export function contextWindow(model, used = 0) {
75
- return lookup(WINDOWS, model) ?? (used > 200_000 ? 1_000_000 : 200_000);
96
+ const guess = used > 200_000 ? 1_000_000 : 200_000;
97
+ const w = lookup(WINDOWS, model);
98
+ return w ? Math.max(w, guess) : guess;
76
99
  }
77
100
 
78
101
  function priceOf(model) {
@@ -123,9 +146,9 @@ export function vecCost(tool, model, v, f, at = Date.now()) {
123
146
 
124
147
  // Codex(OpenAI) API 정가 기준 환산 비용 (USD / 100만 토큰). Claude 와 같이 "API 로 썼다면" 기준이다.
125
148
  // 출처: OpenAI 공식 가격표 https://developers.openai.com/api/docs/pricing 와 모델별 문서
126
- // https://developers.openai.com/api/docs/models/<모델 이름> (2026-11-11 확인, 표의 모든 모델이 공식 값과 같다).
149
+ // https://developers.openai.com/api/docs/models/<모델 이름> (2026-11-18 확인, 표의 모든 모델이 공식 값과 같다).
127
150
  // cacheRead 는 cached input 가격이다. gpt-5.1-codex, gpt-5.1-codex-max, gpt-5-codex 는 가격표에는 없고 모델별 문서에만 있다
128
- // (세 모델 모두 지원 종료). gpt-5.6-sol 값은 2026-11-30 까지의 프로모션 가격이며, 그 뒤 가격은 아직 공개되지 않았다.
151
+ // (세 모델 모두 지원 종료). gpt-5.6-sol 값은 2026-11-30 까지의 프로모션 가격이며, 그 뒤 가격은 2026-11-18 에도 공식 가격표에 없다.
129
152
  // 긴 컨텍스트 단가(입력 272K 초과 요청은 입력 2배·출력 1.5배, gpt-5.6-*, gpt-5.5, gpt-5.4)는 반영하지 않는다:
130
153
  // 세션 누적 토큰만으로는 요청마다 272K 를 넘었는지 알 수 없어서, 모두 기본 단가로 계산한다.
131
154
  // 컨텍스트 창은 Codex 기록의 model_context_window 를 그대로 쓰므로 WINDOWS 표에 넣지 않는다.