Cut over public engine construction to ConfigKit sources

This commit is contained in:
2026-09-30 03:18:49 +00:00
parent 17b6c7bca5
commit ba9c972faa
37 changed files with 1653 additions and 1423 deletions

View File

@@ -19,15 +19,18 @@ func (r *Runner) resolveProfileSelection(
ctx context.Context,
profileID string,
) (*resolvedProfileSelection, error) {
normalizedID := strings.TrimSpace(profileID)
if normalizedID == "" {
lookupID := profileID
if strings.TrimSpace(lookupID) == "" {
return nil, fmt.Errorf("%w: profile id is required", ErrInvalidRequest)
}
if r == nil || r.profiles == nil {
return nil, fmt.Errorf("%w: profile repository is not configured", ErrProfileLoad)
}
if exact, ok := r.profiles.(interface{ ExactIDs() bool }); !ok || !exact.ExactIDs() {
lookupID = strings.TrimSpace(lookupID)
}
selectedProfile, err := r.profiles.GetProfile(ctx, normalizedID)
selectedProfile, err := r.profiles.GetProfile(ctx, lookupID)
if err != nil {
return nil, fmt.Errorf("%w: %w", ErrProfileLoad, err)
}
@@ -37,7 +40,7 @@ func (r *Runner) resolveProfileSelection(
profileValue := *selectedProfile
if profileValue.ResolvedTarget != nil {
return &resolvedProfileSelection{id: normalizedID, profile: &profileValue}, nil
return &resolvedProfileSelection{id: lookupID, profile: &profileValue}, nil
}
profileValue.BackendID = strings.TrimSpace(profileValue.BackendID)
@@ -54,7 +57,7 @@ func (r *Runner) resolveProfileSelection(
}
return &resolvedProfileSelection{
id: normalizedID,
id: lookupID,
profile: &profileValue,
backend: selectedBackend,
}, nil
@@ -80,8 +83,7 @@ func (r *Runner) InspectProfile(
ctx context.Context,
profileID string,
) (*domain.ProfileInspection, error) {
normalizedID := strings.TrimSpace(profileID)
if normalizedID == "" {
if strings.TrimSpace(profileID) == "" {
return nil, fmt.Errorf("%w: profile id is required", ErrInvalidRequest)
}
select {
@@ -90,7 +92,7 @@ func (r *Runner) InspectProfile(
default:
}
selection, err := r.resolveProfileSelection(ctx, normalizedID)
selection, err := r.resolveProfileSelection(ctx, profileID)
if err != nil {
return nil, err
}

View File

@@ -25,7 +25,16 @@ func (r *Runner) resolvePromptDefinition(
return nil, fmt.Errorf("%w: prompt repository is not configured", ErrPromptLoad)
}
definition, err := r.promptDefs.GetPromptDefinition(ctx, promptID, promptVersion)
var definition *domain.PromptDefinition
var hash string
var err error
if indexed, ok := r.promptDefs.(interface {
GetPromptSnapshot(context.Context, string, string) (*domain.PromptDefinition, string, error)
}); ok {
definition, hash, err = indexed.GetPromptSnapshot(ctx, promptID, promptVersion)
} else {
definition, err = r.promptDefs.GetPromptDefinition(ctx, promptID, promptVersion)
}
if err != nil {
return nil, fmt.Errorf("%w: %w", ErrPromptLoad, err)
}
@@ -33,9 +42,11 @@ func (r *Runner) resolvePromptDefinition(
return nil, fmt.Errorf("%w: prompt repository returned nil definition", ErrPromptLoad)
}
hash, err := hashPromptDefinition(definition)
if err != nil {
return nil, fmt.Errorf("%w: failed to hash prompt definition: %v", ErrPromptLoad, err)
if hash == "" {
hash, err = hashPromptDefinition(definition)
if err != nil {
return nil, fmt.Errorf("%w: failed to hash prompt definition: %v", ErrPromptLoad, err)
}
}
return &resolvedPromptDefinition{definition: definition, hash: hash}, nil
}

View File

@@ -339,9 +339,9 @@ func (r *Runner) resolvePreparation(
return nil, fmt.Errorf("%w: output contract: %v", ErrInvalidRequest, err)
}
selectedProfileID := strings.TrimSpace(req.ProfileID)
if selectedProfileID == "" {
selectedProfileID = strings.TrimSpace(def.DefaultProfile)
selectedProfileID := req.ProfileID
if strings.TrimSpace(selectedProfileID) == "" {
selectedProfileID = def.DefaultProfile
}
if selectedProfileID == "" {
return nil, fmt.Errorf("%w: %w: profile id is required either in request or prompt default_profile", ErrInvalidRequest, ErrProfileRequired)