Slim subagent runtime surface and remove legacy interfaces

This commit is contained in:
LPF
2026-03-17 13:41:12 +08:00
parent 341e578c9f
commit 0674d85ae1
76 changed files with 778 additions and 8782 deletions

View File

@@ -318,10 +318,6 @@ func (m *OAuthLoginManager) CredentialFile() string {
return m.manager.cfg.CredentialFile
}
func (m *OAuthLoginManager) StartManualFlow() (*OAuthPendingFlow, error) {
return m.StartManualFlowWithOptions(OAuthLoginOptions{})
}
func (m *OAuthLoginManager) StartManualFlowWithOptions(opts OAuthLoginOptions) (*OAuthPendingFlow, error) {
if m == nil || m.manager == nil {
return nil, fmt.Errorf("oauth login manager not configured")
@@ -351,10 +347,6 @@ func (m *OAuthLoginManager) StartManualFlowWithOptions(opts OAuthLoginOptions) (
}, nil
}
func (m *OAuthLoginManager) CompleteManualFlow(ctx context.Context, apiBase string, flow *OAuthPendingFlow, callbackURL string) (*OAuthSessionInfo, []string, error) {
return m.CompleteManualFlowWithOptions(ctx, apiBase, flow, callbackURL, OAuthLoginOptions{})
}
func (m *OAuthLoginManager) CompleteManualFlowWithOptions(ctx context.Context, apiBase string, flow *OAuthPendingFlow, callbackURL string, opts OAuthLoginOptions) (*OAuthSessionInfo, []string, error) {
if m == nil || m.manager == nil {
return nil, nil, fmt.Errorf("oauth login manager not configured")
@@ -392,10 +384,6 @@ func (m *OAuthLoginManager) CompleteManualFlowWithOptions(ctx context.Context, a
}, models, nil
}
func (m *OAuthLoginManager) ImportAuthJSON(ctx context.Context, apiBase string, fileName string, data []byte) (*OAuthSessionInfo, []string, error) {
return m.ImportAuthJSONWithOptions(ctx, apiBase, fileName, data, OAuthLoginOptions{})
}
func (m *OAuthLoginManager) ImportAuthJSONWithOptions(ctx context.Context, apiBase string, fileName string, data []byte, opts OAuthLoginOptions) (*OAuthSessionInfo, []string, error) {
if m == nil || m.manager == nil {
return nil, nil, fmt.Errorf("oauth login manager not configured")
@@ -746,47 +734,6 @@ func defaultRefreshLead(provider string, overrideSec int) time.Duration {
}
}
func (m *oauthManager) models(ctx context.Context, apiBase string) ([]string, error) {
attempts, err := m.prepareAttemptsLocked(ctx)
if err != nil {
return nil, err
}
if len(attempts) == 0 {
return nil, fmt.Errorf("oauth session not found, run `clawgo provider login` first")
}
var merged []string
seen := map[string]struct{}{}
var lastErr error
for _, attempt := range attempts {
client, err := m.httpClientForSession(attempt.Session)
if err != nil {
lastErr = err
continue
}
models, err := fetchOpenAIModels(ctx, client, apiBase, attempt.Token)
if err != nil {
lastErr = err
continue
}
attempt.Session.Models = append([]string(nil), models...)
_ = m.persistSessionLocked(attempt.Session)
for _, model := range models {
if _, ok := seen[model]; ok {
continue
}
seen[model] = struct{}{}
merged = append(merged, model)
}
}
if len(merged) > 0 {
return merged, nil
}
if lastErr != nil {
return nil, lastErr
}
return nil, fmt.Errorf("no oauth sessions available")
}
func (m *oauthManager) login(ctx context.Context, apiBase string, opts OAuthLoginOptions) (*oauthSession, []string, error) {
if m == nil {
return nil, nil, fmt.Errorf("oauth manager not configured")