iop/apps/node/internal/adapters/cli/status/status.go
toki fefc198dfe refactor: antigravity CLI status 통합 및 문서 업데이트
- antigravity 기반 CLI status adapter 구현 (gemini 대체)
- milestone 파일명 통일 (接두어 제거)
- agent-ops roadmap/current.md 갱신
- edge/node README 및 설정 문서 업데이트
- e2e smoke 스크립트 개선
2026-05-21 21:39:09 +09:00

65 lines
2.1 KiB
Go

package status
import (
"context"
"fmt"
"path/filepath"
"iop/apps/node/internal/runtime"
"iop/packages/config"
)
// UsageStatus represents the parsed usage limits of a CLI target.
type UsageStatus struct {
RawOutput string `json:"raw_output"`
DailyLimit string `json:"daily_limit,omitempty"`
DailyResetTime string `json:"daily_reset_time,omitempty"`
WeeklyLimit string `json:"weekly_limit,omitempty"`
WeeklyResetTime string `json:"weekly_reset_time,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
// ToRuntime converts UsageStatus to the runtime domain type.
func (s *UsageStatus) ToRuntime() *runtime.AgentUsageStatus {
if s == nil {
return nil
}
return &runtime.AgentUsageStatus{
RawOutput: s.RawOutput,
DailyLimit: s.DailyLimit,
DailyResetTime: s.DailyResetTime,
WeeklyLimit: s.WeeklyLimit,
WeeklyResetTime: s.WeeklyResetTime,
Metadata: s.Metadata,
}
}
// Checker defines the interface for checking CLI status/usage.
type Checker interface {
Check(ctx context.Context) (*UsageStatus, error)
}
// CheckUsage creates the appropriate checker and executes it.
func CheckUsage(ctx context.Context, target string, profile config.CLIProfileConf) (*UsageStatus, error) {
checker, err := NewChecker(target, profile)
if err != nil {
return nil, err
}
return checker.Check(ctx)
}
// NewChecker creates the appropriate checker for the given target and profile.
func NewChecker(target string, profile config.CLIProfileConf) (Checker, error) {
cmdBase := filepath.Base(profile.Command)
switch {
case target == "codex" || cmdBase == "codex":
return NewCodexChecker(profile.Command), nil
case target == "claude" || target == "claude-tui" || cmdBase == "claude":
return NewClaudeChecker(profile.Command), nil
case target == "antigravity" || cmdBase == "agy" || cmdBase == "antigravity":
return NewAntigravityChecker(profile.Command), nil
default:
return nil, fmt.Errorf("status check not supported for target %q (command %q)", target, profile.Command)
}
}