필드 테스트를 위해 edge OpenAI-compatible 경로와 node adapter 설정을 확장하고, Jenkins 바이너리 빌드 및 control-plane/web compose 배포 구성을 함께 정리한다.
65 lines
2 KiB
Go
65 lines
2 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 == "gemini" || cmdBase == "gemini":
|
|
return NewGeminiChecker(profile.Command), nil
|
|
default:
|
|
return nil, fmt.Errorf("status check not supported for target %q (command %q)", target, profile.Command)
|
|
}
|
|
}
|