| 117 | } |
| 118 | |
| 119 | func (h *BaseHandlers) taskActorContextForWorkspace( |
| 120 | c *gin.Context, |
| 121 | action string, |
| 122 | expectedWorkspaceID string, |
| 123 | ) (taskpkg.ActorContext, error) { |
| 124 | if h.TaskActorContextResolver != nil { |
| 125 | return h.TaskActorContextResolver(c, action) |
| 126 | } |
| 127 | credentials := agentCallerCredentialsFromRequest(c) |
| 128 | if hasAgentCallerIdentityCredentials(credentials) { |
| 129 | caller, err := h.resolveAgentCallerForWorkspace( |
| 130 | c.Request.Context(), |
| 131 | credentials, |
| 132 | "tasks."+strings.TrimSpace(action), |
| 133 | expectedWorkspaceID, |
| 134 | ) |
| 135 | if err != nil { |
| 136 | return taskpkg.ActorContext{}, err |
| 137 | } |
| 138 | return caller.Actor, nil |
| 139 | } |
| 140 | return taskpkg.DeriveHumanActorContext( |
| 141 | defaultTaskActorRef, |
| 142 | taskOriginKindForTransport(h.transportName()), |
| 143 | "tasks."+strings.TrimSpace(action), |
| 144 | ) |
| 145 | } |
| 146 | |
| 147 | func taskOriginKindForTransport(name string) taskpkg.OriginKind { |
| 148 | normalized := strings.ToLower(strings.TrimSpace(name)) |