MCPcopy Create free account
hub / github.com/compozy/agh / workerTargetForRun

Method workerTargetForRun

internal/daemon/task_role_runtime.go:265–300  ·  view source on GitHub ↗
(
	ctx context.Context,
	taskRecord taskpkg.Task,
)

Source from the content-addressed store, hash-verified

263}
264
265func (r *taskRoleRuntime) workerTargetForRun(
266 ctx context.Context,
267 taskRecord taskpkg.Task,
268) (agentName string, provider string, model string, profile *taskpkg.ExecutionProfile, ok bool, err error) {
269 if taskRecord.Owner != nil && !taskRecord.Owner.IsZero() {
270 owner := *taskRecord.Owner
271 if owner.Kind.Normalize() != taskpkg.OwnerKindPool {
272 return "", "", "", nil, false, nil
273 }
274 return strings.TrimSpace(owner.Ref), "", "", nil, true, nil
275 }
276
277 loaded, err := r.store.GetExecutionProfile(ctx, taskRecord.ID)
278 if err != nil {
279 if errors.Is(err, taskpkg.ErrExecutionProfileNotFound) {
280 return "", "", "", nil, false, nil
281 }
282 return "", "", "", nil, false, err
283 }
284 worker := loaded.Worker
285 if worker.Mode.Normalize() != taskpkg.WorkerModeSelect {
286 return "", "", "", nil, false, nil
287 }
288 // The exact worker name wins; selector lists only provide fallback candidates.
289 agentName = strings.TrimSpace(worker.AgentName)
290 if agentName == "" && len(worker.PreferredAgentNames) > 0 {
291 agentName = strings.TrimSpace(worker.PreferredAgentNames[0])
292 }
293 if agentName == "" && len(worker.AllowedAgentNames) == 1 {
294 agentName = strings.TrimSpace(worker.AllowedAgentNames[0])
295 }
296 if agentName == "" {
297 return "", "", "", nil, false, nil
298 }
299 return agentName, strings.TrimSpace(worker.Provider), strings.TrimSpace(worker.Model), &loaded, true, nil
300}
301
302func (r *taskRoleRuntime) applyActivationScope(activation *taskRoleActivation, taskID string) error {
303 switch activation.Scope {

Callers 1

activationForRunMethod · 0.95

Calls 4

GetExecutionProfileMethod · 0.65
IsZeroMethod · 0.45
NormalizeMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected