( ctx context.Context, taskRecord taskpkg.Task, run taskpkg.Run, )
| 219 | } |
| 220 | |
| 221 | func (r *taskRoleRuntime) activationForRun( |
| 222 | ctx context.Context, |
| 223 | taskRecord taskpkg.Task, |
| 224 | run taskpkg.Run, |
| 225 | ) (taskRoleActivation, bool, error) { |
| 226 | if run.Status.Normalize() != taskpkg.TaskRunStatusQueued { |
| 227 | return taskRoleActivation{}, false, nil |
| 228 | } |
| 229 | switch taskRecord.Status.Normalize() { |
| 230 | case taskpkg.TaskStatusDraft, taskpkg.TaskStatusBlocked, taskpkg.TaskStatusCanceled: |
| 231 | return taskRoleActivation{}, false, nil |
| 232 | default: |
| 233 | } |
| 234 | agentName, provider, model, profile, ok, err := r.workerTargetForRun(ctx, taskRecord) |
| 235 | if err != nil || !ok { |
| 236 | return taskRoleActivation{}, false, err |
| 237 | } |
| 238 | if agentName == "" { |
| 239 | return taskRoleActivation{}, false, nil |
| 240 | } |
| 241 | |
| 242 | activation := taskRoleActivation{ |
| 243 | TaskID: strings.TrimSpace(taskRecord.ID), |
| 244 | RunID: strings.TrimSpace(run.ID), |
| 245 | Scope: taskRecord.Scope.Normalize(), |
| 246 | WorkspaceID: strings.TrimSpace(taskRecord.WorkspaceID), |
| 247 | AgentName: agentName, |
| 248 | Provider: provider, |
| 249 | Model: model, |
| 250 | Channel: taskRunSessionChannel(run), |
| 251 | Title: strings.TrimSpace(taskRecord.Title), |
| 252 | Profile: profile, |
| 253 | Capabilities: append( |
| 254 | append([]string(nil), run.RequiredCapabilities...), |
| 255 | profileRequiredWorkerCapabilities(profile)..., |
| 256 | ), |
| 257 | } |
| 258 | applyTaskRoleDesignation(&activation, run) |
| 259 | if err := r.applyActivationScope(&activation, taskRecord.ID); err != nil { |
| 260 | return taskRoleActivation{}, false, err |
| 261 | } |
| 262 | return activation, true, nil |
| 263 | } |
| 264 | |
| 265 | func (r *taskRoleRuntime) workerTargetForRun( |
| 266 | ctx context.Context, |
no test coverage detected